Load product in magento by SKU or product id

To load product using product id we can use below code.

$product = Mage::getModel('catalog/product')->load($product_id);

We can also load product using SKU. Below is the code for load product using SKU.

$_sku = 'product_sku';
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$_sku);
echo $_product->getName();

Tags: Magento1,

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *