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 🙂

Enabled = 1, Disabled = 2 ??? Bright example of alternative logic

app/code/core/Mage/Catalog/Model/Product/Status.php : 46

const STATUS_ENABLED = 1; const STATUS_DISABLED = 2; 1 2 const STATUS_ENABLED = 1 ; const STATUS_DISABLED = 2 ; To die happy or to die unhappy? That is the question.

app/code/core/Mage/Customer/controllers/AccountController.php : 601

// log in and send greeting email, then die happy ... // die unhappy 1 2 3 // log in and send greeting email, then die happy . . . // die unhappy “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

foreach ($adapters as $adapter) { if (empty($adapter['enabled'])) { unset($adapters); } } $adapters = (array) $adapters; 1 2 3 4 5 6 foreach ( $ adapters as $ adapter ) { if ( empty ( $ adapter [ 'enabled' ] ) ) { unset ( $ adapters ) ; } } $ adapters = ( array ) $ adapters ; 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

/** @var $categoty Mage_Catalog_Model_Categeory */ 1 /** @var $categoty Mage_Catalog_Model_Categeory */ 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

* Temporary moved those $this->getRequest()->getParam('blabla') from the code accross this block 1 * Temporary moved those $ this -> getRequest ( ) -> getParam ( 'blabla' ) from the code accross this block Calendar library that comes with magento. Nice variable naming convention

js/calendar/calendar.js : 1472

Calendar.continuation_for_the_fucking_khtml_browser = function() { 1 Calendar . continuation_for_the_fucking_khtml_browser = function ( ) { Paypal is so… paypal

app/code/core/Mage/Paypal/Model/Cart.php : 485

* Go ahead, try to understand ]:-> 1 * Go ahead , try to understand ] : -> Someone please make this… Anybody? Nobody?

lib/Zend/Mail/Transport/Smtp.php : 115

* @todo Someone please make this compatible * with the SendMail transport class. 1 2 * @ todo Someone please make this compatible * with the SendMail transport class . Life of programmer is full of stupid fixes 🙂

app/code/core/Mage/Adminhtml/controllers/Api/UserController.php : 114

//@FIXME: stupid fix of previous multi-roles logic. 1 //@FIXME: stupid fix of previous multi-roles logic. Thats how you should calculate discounts for your customers

app/code/core/Mage/Tax/Model/Sales/Total/Quote/Discount.php : 32

/** * Calculate discount tac amount * * @param Mage_Sales_Model_Quote_Address $address * @return Mage_Tax_Model_Sales_Total_Quote */ public function collect(Mage_Sales_Model_Quote_Address $address) { // echo 'discount'; } 1 2 3 4 5 6 7 8 9 10 /** * Calculate discount tac amount * * @param Mage_Sales_Model_Quote_Address $address * @return Mage_Tax_Model_Sales_Total_Quote */ public function collect ( Mage_Sales_Model_Quote _ Address $ address ) { // echo 'discount'; } Please contact developers

app/code/core/Mage/Core/Model/Translate.php : 330

/** * Retrieve translation data * * @return array */ public function getData() { if (is_null($this->_data)) { return array(); //Mage::throwException('Translation data is not initialized. Please contact developers.'); } return $this->_data; } 1 2 3 4 5 6 7 8 9 10 11 12 13 /** * Retrieve translation data * * @return array */ public function getData ( ) { if ( is_null ( $ this -> _data ) ) { return array ( ) ; //Mage::throwException('Translation data is not initialized. Please contact developers.'); } return $ this -> _data ; }

More fun with magento

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

Cheers 🙂