2

I want to separate attributes according to product category id on product compare page. means on ../catalog/product/compare/list.phtml

anyone can help me?

3

Try with

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

I know that loading a product in a loop may lead to performance issues but how many products can you have in a comparison list? I think it's safe to say, not that many.

  • $_item is already a product instance, so $ids = $_item->getCategoryIds() should work as well. If not, add the missing fields/joins to the collection. – Fabian Schmengler Nov 11 '14 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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