2/28/2011

How to get product details using product sku in magento

If you know your product SKU you can get details of that products, e.g- you can get Product Id, Product Name, Product Description, Product Price etc.
To get details fo the product by sku please write the below code

$products = Mage::getModel('catalog/product')
$_Pdetails = $product->loadByAttribute('sku', 'product-sku');

or

$_Pdetails =
Mage::getModel('catalog/product')->loadByAttribute('sku','product-sku');

echo $_Pdetails->getName();
echo $_Pdetails->getDescription();
echo $_Pdetails->getPrice();
echo $_Pdetails->getProductUrl();

No comments:

Post a Comment