blog

Magento Custom Attributes in Cart

published in

Magento, Web Development

comments

0

With all the use of custom attributes in Magento lately I finally had a project where I needed to get the attribute information and display this on the product in the cart page. Copy the file:

/app/design/frontend/default/base/template/checkout/cart/item/default.phtml

to your theme (should be /app/design/frontend/default/yourTheme/template/checkout/cart/item/default.phtml ).

Inside this file there is a td tag that renders the product information. While you can get default product data as you would you can not access custom attributes in the same way as the default data – you need to use the getModel method. So for example to get my custom attribute with the value “seat_location” (assigned in the admin panel):

// Get custom attribute in cart
<?php echo Mage::getModel('catalog/product')->load($this->getProduct()->getId())->getAttributeText('seat_location'); ?>

Easy.

This entry was posted in Magento, Web Development and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>