Wednesday, 31 October 2012

Magento : useful functions list

General functions

Function
$this->getRequest()->getServer(‘HTTP_REFERER’);

Product related functions

Function
$product->getName()
$product->getSku()
Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()
$product->getResource()->getAttribute(‘color’)->getFrontend()->getValue($product)
$product->isSaleable()
$product->isisAvailable()
Mage::getModel(‘catalogrule/rule’)->calcProductPriceRule($product,$product->getPrice())
$product->getTierPrice(1)

Newsletter related functions

Function
$subscriber = Mage::getModel(‘newsletter/subscriber’);
$subscriber->subscribe($user_mail);

Cache

Function
$tags = array(Mage_Catalog_Model_Category::CACHE_TAG); //Category block tag
Mage::app()->cleanCache($tags)

Product images

Function
$_product->getMediaGalleryImages()->getItemByColumnValue(‘label’, ‘LABEL_NAME’)->getUrl()

Customer related functions

Function
$this->helper(‘customer’)->isLoggedIn()

2 comments:

  1. Expected and legitimate focuses are incorporated into you blog.. I extremely preferred and I got some unmistakable thoughts for enhance my considerations from very much characterized content...
    Affordable ecommerce development services
    Magento ecommerce development services

    ReplyDelete

Note: only a member of this blog may post a comment.