top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to get product information from product Id?.

+4 votes
48 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 Google+ Share Button LinkedIn Share Button Multiple Social 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...