2 Nov 2013

Magento: Use Mysql Functions With Addexpressionattributetoselect

Function addExpressionAttributeToSelect as defined in Mage_Eav_Model_Entity_Collection_Abstract (/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php) allows us to use MySQL functions in Magento collection. Here is an example of using MYSQL IN() clause in magenot more product collection at once :





Here is an example of using MySQL function CONCAT in Magento customer collection to concat customer’s firstname and lastname:



Here is another example which uses MySQL function MONTH which fetches only month from customer’s birth date.


No comments:

Post a Comment