Magento Product Information : If you are developing Magento template sooner or later you will need to obtain some product information and rearrange it to fit your template. One of the most useful function while working with Magento is Mage::getModel($modelClass).
Here is how you would use it to retrieve Magento product information Mage::getModel(‘catalog/product’);. This ‘catalog/product’ relates to app/code/core/Mage/Catalog/Model/Product.php file. If you open that file you will see it’s actually a class named Mage_Catalog_Model_Product. That same class is extending theMage_Catalog_Model_Abstract class meaning it inherits all of it’s methods. ” $Product = Mage::getModel(‘catalog/product’); $Product->load(164); echo ‘<p>Product name: <strong>’ . $Product->getPrice() . ‘</strong></p>’; ” This tiny code will fetch the data from the ProductID , which i set here 164 . You can fetch all the product information e.g – price,weight , imageurl and many more . |
Be the first to comment.