Some Code Samples In Magento

Share

Some Code Samples In Magento

Get CMS Page ID
$pageId = Mage::getBlockSingleton(‘cms/page’)->getPage()->getIdentifier();

How to get product attributes?
<?php echo $_product->getResource()->getAttribute(‘attribute name’)->getFrontend()->getValue($_product) ?>

How to show breadcrumbs in magento?
<?php echo $this->getLayout()->getBlock(“breadcrumbs”)->toHtml(); ?>

How to show Static Blocks?
<?php /* $this->block_code2call, static block code name – the one added under CMS > Static Blocks */ $_block = Mage::getModel(‘cms/block’) ->setStoreId(Mage::app()->getStore()->getId()) ->load($this->getLayout()->createBlock(‘cms/block’)->setBlockId($this->block_code2call)->getBlockId()); ?>

Get current category
Mage::getModel(‘catalog/layer’)->getCurrentCategory()->getName()

Comments are closed.