top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get product information from product Id?.

+4 votes
269 views
How to get product information from product Id?.
posted May 19, 2015 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
 
Best answer

$_item['product_id'] is a product id . We will find out categoryid associate with product.

$product = Mage::getModel('catalog/product')->load($_item['product_id']);
$cats = $product->getCategoryIds();

Now we have category ID(s). One product can associate with more then one categorys. This is Magento default nature.

foreach ($cats as $category_id) {
    $_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category_id);
        echo $_cat->getName();             
    }

$_cat->getName(); is your product category name. This is beneficial if product is associate with a single category. if product is associate with multiple category then we need category ID to get product category name.

i hope this will little helpful for you

answer May 23, 2015 by Rajneesh
...