Magento Template Development Cheat Sheet - eROI PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

FORUSEINTHE.

PHTMLFILES:
PAGEPATH
<?php echo $this->getUrl('myCMSpage'); ?>
IMAGEPATH
<?php echo $this->getSkinUrl('images/button.gif'); ?>
PRODUCTLINK
<?php echo $this->getProductData()->getProductUrl(); ?>
PRODUCTNAME
<?php echo $this->htmlEscape($this->getProductData()->getName()); ?>
DISPLAYALLOFAPRODUCTSCATEGORIES
<?php $categories = $_product->getCategoryIds();
foreach($categories as $k => $_category_id):
$_category = Mage::getModel('catalog/category')->load($_category_id); ?>
<a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?>
<?php endforeach; ?>
USEASTATICBLOCKINATEMPLATEFILE
<?php echo $this->getLayout()->createBlock('cms/block')->
setBlockId('YOURBLOCKID')->toHtml(); ?>
TESTFORAPRODUCTATTRIBUTE
<?php if ($this->product['attributename'] == "attributevalue") {
// your stuff here
} ?>
TESTIFINCATEGORY
<?php if ($this->getCurrentCategory()->getName() == "My Category") {
//do some stuff
} ?>
CALLANATTRIBUTEONTHEPRODUCTLISTPAGE

<?php if ($_product->getData('attributename')):
$_staff_pick= $_product->getResource()->getAttribute ('attributename')->getFrontend()->g
if ($_attributename == "Yes"){
// DISPLAY ATTRIBUTE
}
endif; ?>
MOREFUNCTIONSTHATMAYCOMEINHANDY

$this->getCurrentCategory()->getImageUrl();
$this->getCurrentCategory()->getDescription();
$this->IsTopCategory();
$this->getProductListHtml();
$this->getCmsBlockHtml();
OTHERPRODUCTATTRIBUTESYOUCANCALL
Using
$this>product['attributename']
syntax:
(ValuesfortheseattributesareherejustasexamplesYourswilllikelybedifferent.)
[store_id] => 1
[entity_id] => 3
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => 2281
[category_ids] => 2,15,17,23,24
[created_at] => 2008-09-09 16:24:03
[updated_at] => 2008-09-15 22:47:51
[has_options] => 0
[name] => ProductName
[url_key] => productname
[gift_message_available] => 2
[meta_title] =>
[meta_description] =>
[image] => /p/r/product_productname.gif
[small_image] => /p/r/product_productname.gif
[thumbnail] => /p/r/product_productname.gif
[custom_design] => default/yourthemefolder
[options_container] => container2
[url_path] => productname.html
[status] => 1
[visibility] => 4
[tax_class_id] => 0
[weight] => 1.0000
[price] => 37.9900
[description] =>
[short_description] =>
[meta_keyword] =>
[custom_layout_update] =>
[media_gallery] => Array
[tier_price] => Array
[stock_item] =>

FORUSEFROMWITHINAMAGENTOCMSPAGE:
CALLASTATICBLOCKFROMWITHINACONTENTAREA

{{block type="cms/block" block_id="your_block_identifier" template="cms/content.phtml"}}


IMAGEPATHFROMWITHINCMS
{{skin url="images/logo.gif"}}

You might also like