Magento Some important functions

0
284

Here I will show you some important functions/methods in Magento that will make your development easy.

Get the path of your magento page.

1
echo $this->getUrl('mypage');

Get the path of the image in your skin folder.

1
echo $this->getSkinUrl('images/yourimage.gif');

Get the product link.

1
echo $this->getProductData()->getProductUrl();

Get the product name.

1
echo $this->htmlEscape($this->getProductData()->getName());

Call a static block in .phtml file.

1
echo $this->getLayout()->createBlock('cms/block')->setBlockId('YOURBLOCKID')->toHtml();

Get Image url of current category.

1
echo $this->getCurrentCategory()->getImageUrl();

Check whether the current category is Top category.

1
echo $this->IsTopCategory();

Get description of current category.

1
echo $this->getCurrentCategory()->getDescription();

Display products list page (list.phtml).

1
echo $this->getProductListHtml();

Display CMS block page.

1
echo $this->getCmsBlockHtml();


Get current store id.

1
echo $storeId = Mage::app()->getStore()->getId();

Get current store name.

1
echo $storeName = Mage::app()->getStore()->getName();

Get current store code.

1
echo $storeCode = Mage::app()->getStore()->getCode();

Get website name.

1
echo $websiteName = Mage::app()->getWebsite()->getName();

Get session id.

1
echo $sessionId = Mage::getModel('core/session')->getSessionId();

Get customer id.

1
echo $customerId = Mage::getModel('customer/session')->getCustomerId();

Get guest id.

1
echo $vistitorId = Mage::getModel('core/session')->getVisitorId();