Magento addColumn to Orders Grid with Options not displaying Values

Magento addColumn to Orders Grid with Options not displaying Values

August 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento addColumn to Orders Grid with Options not displaying Values

Solving Magento Column Display Issues for Order Grid

If you’re facing difficulties displaying values in columns added to the Magento order grid using options, you’ve come to the right place. I understand your frustration, as it can be challenging to pinpoint what’s going wrong when dealing with custom attribute display on grids.

Understanding Your Current Setup

From your code snippet, it appears that you’re correctly defining a new column for the delivery time in the order grid:

$this->addColumn('order_delivery_time', array(
    'header' => Mage::helper('sales')->__('Delivery Time'),
    'index'  => 'order_delivery_time',
    'type'   => 'options',
    'width'  => '70px',
    'options'   =>  array(
        '11:00 AM' => '11:00 AM',
        '1:00 PM'  => '1:00 PM',
        '4:00 PM'  => '4:00 PM'
    )
));

You’ve set the column type to options, which should allow you to display pre-defined options. The issue seems to lie in how Magento handles the rendering of these options.

Identifying the Problem

The problem is that Magento expects the columns defined with type = 'options' to have option IDs and labels that correspond exactly to the values stored in the database for the attribute. In your case, you’re storing values like '11:00 AM', but Magento sees these as option labels rather than actual options.

The Solution: Mapping Option IDs

To resolve this issue, you need to map the option IDs to match the values being saved in the order_delivery_time column. Here’s how you can do it:

First, when saving your delivery time options, make sure they have unique and consistent IDs like '11_am', '1_pm', and '4_pm' instead of their full labels.

Then, update your code to map these option IDs back to the actual labels:

$this->addColumn('order_delivery_time', array(
    'header' => Mage::helper('sales')->__('Delivery Time'),
    'index'  => 'order_delivery_time',
    'type'   => 'options',
    'width'  => '70px',
    'option_id_field' => 'delivery_option_id', // This field should exist in your options table
    'options'   => Mage::getModel('yourmodule/option')->getOptionArray(),
));

In this updated code:

  • Replace 'yourmodule' with the actual name of the module where you’ve defined your delivery time options.
  • delivery_option_id is a placeholder for the field in your options table that contains the unique option IDs.

Conclusion

Remember, when working with Magento’s grid columns, it’s crucial to ensure consistency between the database values and the options used in the column definition. Mapping the option IDs correctly will solve the display issue you’re encountering.

If you find yourself in need of more advanced customizations or want to explore how Laravel can be leveraged for e-commerce projects like these, feel free to check out Laravel Company’s services.

Don’t hesitate to reach out if you require further assistance. Happy coding!

Database Admin Orders Errors

Our network