I want to add a custom checkbox to all orders that is by default deactivated, allow the admins to change the value of this field in the backend and filter the grid by this!

What I have so far is:

Module config:

<?xml version="1.0"?>


The setup file:

$installer = $this;
$installer->addAttribute("order", "handled", array("type" => "checkbox", 'label' => 'Order handled', 'visible' => true, 'required' => false, 'is_user_defined' => true,));

The demo/ordercheckbox.xml:

<?xml version="1.0" ?>
        <reference name="sales_order.grid">
            <action method="addColumnAfter">
        <!-- apply layout handle defined above -->
        <update handle="sales_order_grid_update_handle" />
        <!-- apply layout handle defined above -->
        <update handle="sales_order_grid_update_handle" />

In the grid, there is a new field, but it is checked for every order and if I try to filter by it, there is an error a:5:{i:0;s:85:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'handled' in 'where clause'";i:1;s:6103:"#0 /home/web/htdocs/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

How do I get this to work? Then I need to make it changeable in the detail view. I added this code to app/design/adminhtml/default/default/template/sales/order/view/form.phtml

$_order_id = $this->getRequest()->getParam('order_id');
if ($_order_id>0):
$_order = Mage::getModel('sales/order')->loadByIncrementId($_order_id);
<div class="entry-edit" id="sales_order_view"><div id="handled-status"><span class="bold">Already handled</span>  <input type="checkbox" name="handled"<?php if($isHandled) { echo ' checked '; } ?> value="true" id="handledCheckbox"></div></div>
<script type="text/javascript">
var clickHandler = function() {
  var ch = jQuery(this);
  res = false; //add here ajax call to update status
  ch.prop('checked', res);

I plan to add a method to change this value to my module and call that method using AJAX!

Should my approach work after I fix the errors/problems or am I completely on the wrong track?

  • 2
    What class is your setup class extending?
    – benmarks
    Feb 15, 2015 at 18:00

1 Answer 1


I guess the problem is that you set-up script did not run correctly and so the attribute was not added to the order table.

Please check the following:

  1. core_resource table for an entry Ordercheckbox_setup,
  2. Possibly it does not like the upper case name so try to update it to ordercheckbox_setup and update the folder,
  3. Validate that the folder naming and script naming is correct,

Your Answer

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

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