PHP, Magento, Codigniter, Opencart and Wordpress Developer. Contact for school and college projects on PHP, Codiegniter, Wordpress, Mysql etc.
Saturday, 30 January 2016
How to display category name by product id in Magento
If you want to get Category Name by Product Id in Magento. Use following code:
<?php
$product = Mage::getModel('catalog/product')->load($_product->getId());
$cat_id = $product->getCategoryIds();
foreach($cat_id as $categorycbId) {
$category_id = Mage::getModel('catalog/category')->load($categorycbId);
echo $category_id->getName();
}
?>
Friday, 29 January 2016
How to display static block with title in phtml file : Magento
If you want to display static block in PHTML file in Magento. We can use following code:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>
But If you want to display static block with title. So, we can you following code:
<?php
$block = Mage::getModel('cms/block')--->load('identifier');
echo $block->getTitle();
echo $block->getContent();
?>
Subscribe to:
Posts (Atom)