Friday, March 16, 2012
Useful code in Magento
Magento Home URL- Mage::getBaseUrl();Magento Home Directory- Mage::getBaseDir();URL of a file in the skin directory- $this->getSkinUrl(‘images/myfile.png’); // in a template or Block- Mage::getDesign()->getSkinUrl(‘images/myfile.png’); // from anywhereFormat a price value- Mage::helper(‘core’)->formatPrice($amount);Get the display value of a (multi-)select product attribute- echo $product->getAttributeText(‘manufacturer’);Create an object instance in magento- Mage::getModel(‘module/class’); // for models- Mage::helper(‘module/class’); // for helpers- Mage::app()->getLayout()->createBlock(‘module/class’, ‘name_in_layout’); // for blocksGET/POST parameters- Mage::app()->getRequest()->getParam(‘param_name’); // single parameter- Mage::app()->getRequest()->getParams(); // all parametersGet the Id of the curent store view- Mage::app()->getStore()->getId();Get all Store Views- Mage::app()->getStores(); // pass true to include the admin store view, tooGet the configurable/grouped/bundled product a simple product belongs to- $simpleProduct->loadParentProductIds();- $parentProductIds = $simpleProduct->getParentProductIds();Get the simple products assigned to a configurable product$configProduct->getTypeInstance()->getUsedProductCollection($configProduct);Get an instance of an attributeMage::getSingleton(‘eav/config’)->getAttribute($entityType, $attributeCode);
Labels:
Magento
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
[フレーム]