I want get category ID of products on wishlist and compare page (on wishlist and compare pages I add products of different categories).

On the helper of my module I write:


(and then ->getId())but I get NULL (on other pages - GOOD!)

When on the helper of my module I write:


I get category Id of last category. It's wrong for me, becouse in wishlist or compare there are product of different categories.

2 Answers 2


You can add add new Row in catalog/product/compare/list.phtml

header <th> field as category id and in detail <td> field get the category of product.

You will get array of category ids.

foreach($categories as $category)
   echo Mage::getModel("catalog/category")->load($category)->getName();

In same way you can try for wishlist.


I write function to my block

    public function getCategory()
    $_product = Mage::getModel('catalog/product')->load($_item->getId());
    $ids = $_product->getCategoryIds();
    $category = (isset($ids[0]) ? $ids[0] : null);
    return $category;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.