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 : 4612const 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 : 601123// 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 : 84123456foreach ($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 : 1621/** @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 : 7291* 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 : 14721Calendar.continuation_for_the_fucking_khtml_browser = function() { - Paypal is so… paypal
app/code/core/Mage/Paypal/Model/Cart.php : 4851* Go ahead, try to understand ]:-> - Someone please make this… Anybody? Nobody?
lib/Zend/Mail/Transport/Smtp.php : 11512* @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 : 1141//@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 : 3212345678910/*** 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 : 33012345678910111213/*** 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
- Quick meme magento collection
- Series of comics by Inchoo team
- Magento Darwin Awards contest
If you have more funny pieces of code you want to share – add them in comments
Cheers ๐
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.
Backwards compatibility :)))))))
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! ๐