Add JavaScript or CSS in Block class

 To add JavaScript or CSS files to the head section of the resulting HTML page, you can add something like this to the _prepareLayout function of a Block class: $headBlock = $this->getLayout()->getBlock(‘head’); $headBlock->addJs(‘somefolder/ask-sheldon.js’); $headBlock->addCss(‘somefolder/ask-sheldon.css’); As you can see, we can use the layout model to get the head block an use its functions to add files. This […]

Add breadcrump in custom block

This is how to add a Breadcrumb entry in an own block: $breadcrumbs = $this->getLayout()->getBlock(‘breadcrumbs’); $breadcrumbs->addCrumb(‘home’, array(‘label’=>Mage::helper(‘cms’)->__(‘Home’), ‘title’=>Mage::helper(‘cms’)->__(‘Go to Home Page’), ‘link’=>Mage::getBaseUrl())); $breadcrumbs->addCrumb(‘cms_page’, array(‘label’=>$page->getTitle(), ‘title’=>$page->getTitle()));

Magento – Get all stores

Here is how to get all stores of your Magento instance a an Array: <?php $aAllStores = Mage::app()->getStores(); foreach ($aAllStores as $iStoreId => $oVal){ $sStoreCode = Mage::app()->getStore($iStoreId)->getCode(); $sStoreName = Mage::app()->getStore($iStoreId)->getName(); $iStoreId = Mage::app()->getStore($iStoreId)->getId(); echo $sStoreCode; echo $sStoreName; echo $iStoreId; } ?> To include the admin store you can call getStores like that: $aAllStores = Mage::app()->getStores(true) […]