cancel
Showing results for 
Search instead for 
Did you mean: 

Display product attributes on checkout review page

Display product attributes on checkout review page

German law requires us to display "significant characteristics" of each product on the checkout review page. These are usually product attributes and could easily be fetched by something like this:

<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$attributes = $_product->getAttributes();
foreach ($attributes as $attribute) {
if ($attribute->getIsVisibleOnFront()) {
$value = $attribute->getFrontend()->getValue($_product);
}
}
?>

However as we all know, this isn't best practice and has a negative effect on performance.

I found this guide (https://www.atwix.com/magento/accessing-custom-attribute-at-checkout-or-cart/) describing an alternative approach, however I can not get it to work. Has anybody implemented this and is willing to share the code? Thanks!

1 REPLY 1

Re: Display product attributes on checkout review page

it should work, refresh config cache?

 

If you want to use attributes visible on front instead of modifying config xml, you can create an observer for 'sales_quote_config_get_product_attributes' event

pubic function addVofAttributes($observer) {
        $oldattributes = $observer->getAttributes();
        /* @var $configResource Mage_Catalog_Model_Resource_Config */
        $configResource = Mage::getResourceModel('catalog/config');
        $adapter = $configResource->getReadConnection();

        $select  = $adapter->select()
            ->from(array('main_table' => $configResource->getTable('eav/attribute')), array('attribute_code'))
            ->join(
                array('additional_table' => $configResource->getTable('catalog/eav_attribute')),
                'main_table.attribute_id = additional_table.attribute_id',
                array()
            )
            ->where('main_table.entity_type_id = ?', (int)$configResource->getEntityTypeId())
            ->where('additional_table.used_in_product_listing = ?', 1);
        $attributes = $adapter->fetchCol($select);
        $attributes = array_fill_keys($attributes, '');
        $attributes = $oldattributes + $attributes;
        $observer->setAttributes($attributes);
}