I have tried a lot of stuf but none of them work. I think I can get the custom attributes on the product page, but I was wondering: how to get them in shopping cart page? (the attribute is just a simple written text)
$_item->getProduct()->load()
will reload all product data from the database. While this will work, bear in mind that every time you call load()
Magento will execute a database query.
The same can be done with much better performance by loading the attribute along with the quote item. Just create a custom module and add this to the config.xml
<global>
<sales>
<quote>
<item>
<product_attributes>
<one_custom_attribute_code />
<another_custom_attribute_code />
</product_attributes>
</item>
</quote>
</sales>
</global>
Having done that, you can access your custom attribute without additional database queries.
$_item->getProduct()->getAnotherCustomAttributeCode();
Here is an article about this: https://www.atwix.com/magento/accessing-custom-attribute-at-checkout-or-cart/