1

I'm trying to show the category of each product in my wishlist table. So each product has to show the category it is in in the table on the account page of Magento.

Please see screenshot attached. So instead of "Bekijk Categorie" in the Tbody it should show the name of the category and link to it.

Thanks in advance! enter image description here

1

This can be accomplished in a couple of steps:

  1. Add a new column with layout XML:

The easiest way to do this part is to copy

[magento-root]/app/design/frontend/base/default/layout/wishlist.xml

into your sub-theme:

[magento-root]/app/design/frontend/[custom]/[theme]>/layout/wishlist.xml

After the Product Defaults and Comment section on line 87, add the following snippet:

    <block type="wishlist/customer_wishlist_item_column_comment" name="customer.wishlist.item.category" template="wishlist/item/column/category.phtml">
      <action method="setTitle" translate="title">
        <title>Product Category</title>
      </action>
    </block>
  1. Create the template file

[magento-root]/app/design/frontend/[custom]/[theme]/template/wishlist/item/column/category.phtml

    <?php
    /* @var Mage_Wishlist_Model_Item $item */
    $item = $this->getItem();
    $product = $item->getProduct();
    $categories = $product->getCategoryIds();

    foreach($categories as $id) {
            $cat = Mage::getModel('catalog/category')->load($id);
            echo '<p><a href="/'.$cat->getUrlPath().'">'.$cat->getName().'</a></p>';
    }
    ?>

Then just add some CSS to to make it look the way you want it to. Hope this helps!

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.