Do you have a product’s sku but need to load an actual product object? That is perplexing, huh? Well, never fear! Magento has a way for you to fetch the product ID so you can load that elusive object after all.
Magento’s product object loads it’s product data via the product ID. You can fetch that ID via the
getIdBySku() method inside
Mage_Catalog_Model_Product located in
$product = Mage::getModel('catalog/product');
$productId = $product->getIdBySku('sku');
loadByAttribute()method as well. It’s located in the same file.
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$sku);