Subesh Pokhrel

Magento Developers Blog

Tywin Lannister Quote

A nice quote by Tywin Lannister taken from A Storm of Sword book.

The greatest fools are ofttimes more clever then the men who laugh at them.

Tywin Lannister A Storm of Swords

Magento Block Caching Not Working - Try Using Magento Protected Constructor

You have tried a lot to use Magento block caching, described in here but still your block is not being cache. Here’s a solution do not use the public constructor to write your block cache data, just use the protected constructor to add the data. Then you will see your block will be cached. In fact I think we should always used protected constructor to initialize anything on Magento. Am I right or what do folks has to say about this?

MagNotes Series : Magento Get Store by Store Code

About MagNotes Series In this blog I have always shared about what I’ve learned on Magento, which I felt is taken me one step closer to understanding Magento and Magento development. But during the course of time, I bump on some elementary things which are absolutely required. So just for those elementary things I’ve decided to create a series (MagNotes Series) , for myself as a reference or for whoever think this is helpful.
[source lang=”php”] protected function _getStoreByCode($storeCode) { $stores = array_keys(Mage::app()->getStores()); foreach($stores as $id){ $store = Mage::app()->getStore($id); if($store->getCode()==$storeCode) { return $store; } } return false; } [/source]

MagNotes Series : Magento Get Locale Options as Single Array

About MagNotes Series In this blog I have always shared about what I’ve learned on Magento, which I felt is taken me one step closer to understanding Magento and Magento development. But during the course of time, I bump on some elementary things which are absolutely required. So just for those elementary things I’ve decided to create a series (MagNotes Series) , for myself as a reference or for whoever think this is helpful.
[source lang=”php”] // Get all the locale options $locale = new Mage_Adminhtml_Model_System_Config_Source_Locale(); $localSource = $locale->toOptionArray(); // Change Options array to one dimentional array $localSourceCodes = array(); foreach ($localSource as $source) { $localSourceCodes [$source [‘value’]] = $source [‘label’]; } [/source]

MagNote Series : Magento Get Default Store

In this blog I have always shared about what I’ve learned on Magento, which I felt is taken me one step closer to understanding Magento and Magento development. But during the course of time, I bump on some elementary things which are absolutely required. So just for those elementary things I’ve decided to create a series (MagNotes Series) , for myself as a reference or for whoever think this is helpful.
[source lang=”php”] Mage::app()->getStore(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID); [/source]