Load Category or Product By Attribute (SKU, Name etc) In Magento | Magento Tutorials


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Load by name
  2. $_category = Mage::getModel('catalog/category')->loadByAttribute('name', 'Acoustic Guitars');
  3. $_product = Mage::getModel('catalog/product')->loadByAttribute('name', 'Cordoba Classic 6-String Guitar');
  4.  
  5. // Load by SKU
  6. $_product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'cordoba-classic-6-String-guitar');
  7.  
  8. //Load by ID (just load):
  9. $_product = Mage::getModel('catalog/product')->load($productID);

URL: http://fishpig.co.uk/2010/04/21/load-a-category-or-product-by-an-attribute-sku-name-etc/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.