Yet another blog (hopefully a useful one though)
Magento – Handy code snippets

Here’s a short list of magento codes to do some of the simple stuff. It’s a little empty at the moment but I’ll keep adding to it over time.
- Check if customer is logged in
<?php $_customer = Mage::getSingleton('customer/session')->isLoggedIn(); if ($_customer) { // do stuff } ?>
- Get product image
<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>
- Show image using current skin path (PHTML)
<img src="<?php echo $this->getSkinUrl('images/logo.png');?>" alt="logo" />
- Show image using current skin path (CMS)
<img src={{skin url="images/logo.png"}} />
- Show a custom block (CMS)
{{block type="catalog/product_featured" name="product_featured" as="product_featured" template="catalog/product/featured.phtml"}}
- Show a custom block (XML)
<block type="catalog/navigation" name="catalog.myblock" after="-" template="catalog/navigation/myblock.phtml"/> - Show CMS block (PHTML)
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('my_block_identifier')->toHtml() ?>
- Show short version of review summary
<?php echo $this->getReviewsSummaryHtml($_link,"short",true) ?>
Suggestions for any more helpful code snippets are more than welcome!
Ben
Creative Lead
MS Internet
June 16, 2010 - 3:48 pm
Great article, i
hope can know much information About it!