Magento useful functions cheatsheet
Under construction!!
General functions
Function | Description |
---|---|
$this->getRequest()->getServer(‘HTTP_REFERER’); | Get the referer URL |
Product related functions
Function | Description |
---|---|
$product->getName() | Get product name |
$product->getSku() | Get product sku |
Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty() | Get product stock |
$product->getResource()->getAttribute(‘color’)->getFrontend()->getValue($product) | Get a product attribute value (like color/size) |
$product->isSaleable() | checks if a product is salable |
$product->isisAvailable() | checks if a product type is salable |
Mage::getModel(‘catalogrule/rule’)->calcProductPriceRule($product,$product->getPrice()) | Gets the product final price after all catalog rules have been applied |
$product->getTierPrice(1) | Gets the product tier price if can be applied to the customer |
Newsletter related functions
Function | Description |
---|---|
$subscriber = Mage::getModel(‘newsletter/subscriber’); $subscriber->subscribe($user_mail); |
Add mail to subscribers list |
Cache
Function | Description |
---|---|
$tags = array(Mage_Catalog_Model_Category::CACHE_TAG); //Category block tag Mage::app()->cleanCache($tags) |
Clean specific cache tag (in this case the category list block) |
Product images
Function | Description |
---|---|
$_product->getMediaGalleryImages()->getItemByColumnValue(‘label’, ‘LABEL_NAME’)->getUrl() | Get the url of a specific produc image given its label |
Customer related functions
Function | Description |
---|---|
$this->helper(‘customer’)->isLoggedIn() | Checks if the customer is logged |
Magento is huge and no single blog post could even begin to cover all the available functions ( people have written entire books on the subject!). https://www.cloudways.com/blog/magento-functions-cheat-sheet/
ReplyDeleteYou there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. campingplatz holland mit hund
ReplyDelete