Thursday, January 12, 2012

Magento: Product details from Product ID.


Product details from Product ID

<?php
$model = Mage::getModel('catalog/product') //getting product model
 
$_product = $model->load($productid); //getting product object for particular product id
 
echo $_product->getShortDescription(); //product's short description
echo $_product->getDescription(); // product's long description
echo $_product->getName(); //product name
echo $_product->getPrice(); //product's regular Price
echo $_product->getSpecialPrice(); //product's special Price
echo $_product->getProductUrl(); //product url
echo $_product->getImageUrl(); //product's image url
echo $_product->getSmallImageUrl(); //product's small image url
echo $_product->getThumbnailUrl(); //product's thumbnail image url  
 
?>

If you don’t have product id , you can get like this
<?php
$model = Mage::getModel('catalog/product'); //getting product model
$collection = $model->getCollection(); //products collection
foreach ($collection as $product) //loop for getting products
{
    echo $product->getId().'<br/>';
 
}
?>

6 comments:

  1. Hey! How can i get the storeID in which this product belongs to?

    ReplyDelete
  2. Retrieve Store Id as
    $_product->getStoreId();

    And get all sotre ids where product is presented as
    $_product->getStoreIds();

    ReplyDelete
  3. @Bhoopendra Dwivedi Thanks for your comment.Thats saved lot of time to get product store id

    ReplyDelete