I'd created a custom attribute for customer and in order collection I need to show that attribute. How could I do that?

for now I'd got the order collection as

$collection = Mage::getModel('sales/order')->getCollection()
                ->addFieldToFilter('status', array('eq' => 'complete'))
                ->addAttributeToFilter('customer_group_id', $customer_group)

The attribute I'd created is coachid which need to displayed in this collection. Anyone could help?

  • Could you perhaps provide the information on how you created the custom attribute as i'm having a similar problem to yourself thanks Mohammed
    – Zabs
    Commented May 8, 2014 at 11:50
  • @Zabs: see this blog Commented May 8, 2014 at 13:36

1 Answer 1


I think the best approach is to "copy" the customer field to the order object, because the data might change or the customer can be deleted, but the order info must remain.

For this, add the field coachid to the quote and order tables but prefix it with customer_.

Here is an update script you can use:

$this->run("ALTER TABLE `{$this->getTable('sales/quote')}` ADD COLUMN `customer_coachid` VARCHAR(255) NOT NULL DEFAULT ''");
$this->run("ALTER TABLE `{$this->getTable('sales/order')}` ADD COLUMN `customer_coachid` VARCHAR(255) NOT NULL DEFAULT ''");

Then, tell magento to copy this attribute to the quote and the order.
Add this in the config.xml of one of your modules inside the <global> tag.


Clear the cache.

As a positive side effect you will see the value of this field in the admin order view screen through the magic of Mage_Adminhtml_Block_Sales_Order_View_Info::getCustomerAccountData.


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.