I'm trying to call a custom attribute in the cart.phtml and success.phtml pages so that a module can see the text that is contained. The attribute is a dropdown that isn't visible on the frontend at all.

The attribute contains a keyword that the module searches for, if the keyword is found, different finance options appear.

I've got this working on the product page by adding the following to view.phtml and it works perfectly but using the same/similar code on cart.phtml and success.phtml does not work:


I've done some searches and found that I needed to create a custom module and add the attribute in the config.xml of this module but that didn't work. My php knowledge isn't great so I'm sure I'm missing something.

This is what the snippet of code looks like from cart.phtml:

$prodname = "";

    foreach ($cart->getAllItems() as $item):
        $prodname .= "|||".$item->getProduct()->getAttributeText('my_attribute').$item->getProduct()->getName();

I've also tried with $_item and without the ->getProduct() with no luck.

In the admin panel I can see my custom module where I've put the config.xml is enabled. This is the config.xml:

                        <my_attribute />

Help me stackexchange, you're my only hope

2 Answers 2


If you are not getting your custom attribute value/text, then you can try to load the product using id that you will get from $item->getProduct()->getData(). I think $item->getProduct() is not loading all data that is why you are getting your custom product attribute data.


In your foreach loop, try:

$product = Mage::getModel('catalog/product')->load($item->getProduct()->getId());

This however will have impact on your site performance. See https://stackoverflow.com/questions/19379792/magento-get-a-custom-attribute-value-without-loading-the-entire-product for possible improvement.

Alternatively you can implement a custom collection load with only the attribute you want to prevent too many call to the db.

  • Thanks for the suggestion but that didn't work. I tried the suggestion in the other thread and had no luck also. Feb 19, 2018 at 11:13

Your Answer

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

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