Magento References

Caching Magento Blocks

class My_Custom_Block extends Mage_Catalog_Block_Product_View_Abstract { protected function _construct() { // the $groupId make it so each customer group will be cached separately $groupId = Mage::getSingleton(‘customer/session’)->getCustomerGroupId(); $this->addData(array( ‘cache_lifetime’ => 5600, ‘cache_tags’ => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG), // you can add anything to the cache_key to make it cache separate versions for different customers and stores ‘cache_key’ => “custom_unique_name_{$groupId}” […]

Magento Redirect in Controller with Parameters

Magento controllers come built in with a _redirect() function that gives you the option to add parameters. This includes GET parameters and Magento’s path parameters. This is the basic syntax: $this->_redirect($url,$paramsArray); The $url parameter is the magento url where you would like to redirect to. The $paramsArray is an array that contains the parameters you […]

Using Magento config to run cron jobs

The days of using crontab to run cron jobs for your Magento installation are long over. Since Magento Community Edition 1.8 (Enterprise Edition 1.13) cron jobs can now be configured using the Magento configuration. Initial Setup Before you can schedule your cron jobs, you have to set up Magento’s cron.php or cron.sh using crontab. This […]

Loading Magento Frontend in Server Crontab

Disclaimer: This is not best practices, use the Magento cron system whenever possible. This method should only be used when working on legacy systems that use the server crontab. Any event observers set in the frontend or adminhtml typically won’t fire when a server crontab processes a scheduled job. Any easy solution for this is […]