Posted By

dmistriotis on 08/11/10


Tagged

magento


Versions (?)

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


 / Published in: PHP
 

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

  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);

Report this snippet  

You need to login to post a comment.