Friday, October 21, 2011

Magento's isInStock ... yeah right ;(

OK, now I'm confused (more than usual ;)) ... why on the earth they did this (maybe they just hate me ;))

While I was looking for the name of event fired when product is in stock status is checked I found this "gem" of the code in Mage_Catalog_Model_Product:

    public function isInStock()
    {
        return $this->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
    }

WTF?!?

So ... $product->isInStock() will always return TRUE if product is enabled ... WHAT!?! Who put (or left) that stupidity in the code!???

And real stock check is:

    /**
     * Check is product available for sale
     *
     * @return bool
     */
    public function isSalable()
    {
        Mage::dispatchEvent('catalog_product_is_salable_before', array(
            'product'   => $this
        ));

        $salable = $this->isAvailable();

        $object = new Varien_Object(array(
            'product'    => $this,
            'is_salable' => $salable
        ));
        Mage::dispatchEvent('catalog_product_is_salable_after', array(
            'product'   => $this,
            'salable'   => $object
        ));
        return $object->getIsSalable();
    }

And yeah, there is also isSaleable (typo?) alias ... Huh!?

Whenever I look into Magento core code I get ton's of the possible great posts for the The Daily WTF! :D

In the end one can hope that they (and no one else) did not used isInStock method for checking if product is in stock!!!!

Sunday, October 9, 2011

Development tools

Setting up (yet another) MacBook before trip to client I got to re-visit all of my tools I use to work on Magento (and almost all other programing stuff I'm working on) so I decided to (finally) make I list of stuff I always install/use.

OS: OS X

It Just Works.

After years of maintaing all of the popular OSes one learns to appreciate that simple and yet powerful quote.

I do use Linux on my PC but I still can't find good replacements for tools I'm using on OS X. I even have Windows lying around, but only for gaming, development on Windows is ... (let's not go here ;))

Editor: TextMate

After a years of searching I still can't find anything better -- simple, extendable, fast ... (i do use Geany on Linux too). With the right collection of bundles it's simply unbeatable (I did use vim, emacsen, ... but let's not start editor wars all over again :))

And as icing on the cake 2.0 is just around the corner!

Story about using TextMate would not be complete without some of the great bundles I'm using with it

GetBundle

(some links are dead so I'm linking on TextMate blog entry instead)

Easiest way to get one of the zillion bundles for the TextMate

Using it it is easy to get Python, PHP, Validate On Save, Git related and all other bundles which make development much more easier.

Full screen on Lion

I'm the first one when complaining about people using full screen windows on modern monitors, but ... on 13" MacBook new Lion's fullscreen mode begins to shine, especially coupled with multitouch gestures.

Missing Drawer

This is a great companion for the full screen bundle as TextMate's full screen mode is missing project driver without it. Also adds neat little button for opening terminal window directly from within project drawer.

VCS: GIT

Enough said. No developer should work without some VCS in place ... never. GIT is my favorite almost from the moment I first saw it. Distributed VCS FTW!

Source Tree

Source Tree is nice GIT/HG GUI wrapper, and it's free :)

Terminal.app

I do spend rest of my development time in it (when I do not write code in editor) and anyone trying to develop on Win knows why it's on the list.

FTP/SFTP/... client: Cyberduck

Simply the best client on OSX and Win.

Browsers: All of them

Enough said ... someone please, please, please ... kill (or if that's possible fix) that IE ... please!!!!! And while at it ... hit Flash for me ... hard!

Magento

Pffff ... well ... ummm ...

I don't want to fill this entry with lot of the nasty words ... It's a shame that their software designs skills are not good as their marketing skills.

Hopefully 2.0 team will learn how to design something which is not ...

PHP

PHP language design is ... lacking to say it mildly ...

Python

OS X of the programing languages -- It Just Works!


Ouch, this is turning in real big wall of text ... better to wrap it up

to be continued...

Saturday, May 8, 2010

WinMerge

Another nice one in toolkit great diff tool nicely integrated in rclick menu.

Wednesday, May 5, 2010

WinSCP

Main thing which I was missing on filezilla was need to confirm upload when editing remote files (damn I miss Cyberduck)

WinSCP has it and on plus side it can be made to look just like TotalCommander :D

KeePass Password Safe

One of small tool jewels for anyone who needs to keep tracks of lot's of account/passwords. It keeps them in AES/Twofish encrypted file, can auto-type username/password in most of dialogs/shells and also can "drag" that trough clipboard to add even more protection from keyloggers. Did I mention that it can organize all needed passwords very nicely :)

As password file is encrypted is fairly safe to keep backup of it on dropbox for example - no more hunting for lost passwords :)

And it's Open Source :)

Tuesday, April 13, 2010

My magento .gitignore

Based on Git ignore (.gitignore) file for Magento project I started working on my version of it. I published it as gist on GitHub so it will be easier to maintain. Here it is:


Monday, April 12, 2010

SubSwitch

SubSwitch is a great Thunderbird addon if you have need to organize your email, it help adding meaningful subject lines to outgoing mails just like I used with various mailing lists (like [Foo]) so latter filtering will be very easy.

Only problem I did found is that saving preferences do not work on *NIX version of Thunderbird 3, probably some permission problems.