Funny pieces of code in Magento

Funny pieces of code in Magento

If you working a lot with magento you might seen some of these. Check the collection of funny pieces of code and comments in magento. Someone might found it sad. It’s up to you ๐Ÿ™‚

  1. Enabled = 1, Disabled = 2 ??? Bright example of alternative logic
    app/code/core/Mage/Catalog/Model/Product/Status.php : 46
  2. To die happy or to die unhappy? That is the question.
    app/code/core/Mage/Customer/controllers/AccountController.php : 601
  3. “All for one and one for all”. Just try to disable one adapter and we destroy them all.
    app/code/core/Mage/Api2/Helper/Data.php : 84
  4. I affirm that you do not write category word correct from the first time. And from the second time ๐Ÿ™‚
    app/code/core/Mage/Catalog/Model/Layer/Filter/Category.php : 162
  5. Welcome to the Land Of The Temporary Eternity. This code here since magento 1.1
    app/code/core/Mage/Adminhtml/Block/System/Config/Form.php : 729
  6. Calendar library that comes with magento. Nice variable naming convention
    js/calendar/calendar.js : 1472
  7. Paypal is so… paypal
    app/code/core/Mage/Paypal/Model/Cart.php : 485
  8. Someone please make this… Anybody? Nobody?
    lib/Zend/Mail/Transport/Smtp.php : 115
  9. Life of programmer is full of stupid fixes ๐Ÿ™‚
    app/code/core/Mage/Adminhtml/controllers/Api/UserController.php : 114
  10. Thats how you should calculate discounts for your customers
    app/code/core/Mage/Tax/Model/Sales/Total/Quote/Discount.php : 32
  11. Please contact developers
    app/code/core/Mage/Core/Model/Translate.php : 330

More fun with magento

  1. Quick meme magento collection
  2. Series of comics by Inchoo team
  3. Magento Darwin Awards contest

If you have more funny pieces of code you want to share – add them in comments

Cheers ๐Ÿ™‚

4 thoughts on “Funny pieces of code in Magento

  1. One of my favourites is code/Mage/Catalog/Model/Product.php, line 1364:

    /**
    * Alias for isSalable()
    *
    * @return bool
    */
    public function isSaleable()
    {
    return $this->isSalable();
    }

    Typoed the function name? Bah, just create an alias.

  2. My attempt:


    /**
    * Subtracts hours from the existing date object.
    * The hour is always a number.
    * Returned is the new date object
    * Example: 04.May.1993 13:07:25 -> subHour(6); -> 05.May.1993 07:07:25
    *
    * @param string|integer|array|Zend_Date $hour Hour to sub
    * @param string|Zend_Locale $locale OPTIONAL Locale for parsing input
    * @return Zend_Date Provides fluid interface
    * @throws Zend_Date_Exception
    */
    public function subHour($hour, $locale = null)
    {
    return $this->_calcvalue('sub', $hour, 'hour', self::HOUR_SHORT, $locale);
    }

    This is from: Zend_Date class.

    Hint: You add 6 hours to May 4th and end up with May 5th! ๐Ÿ˜€

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.