I have created a custom attribute which is the customer account reference and we set this in the back end through the customer page. However we need to add this to the Sales order grid as well. I created my Attribute using this:
http://codemagento.blogspot.co.uk/
This is my sql file:
<?php
$installer = $this;
$installer->startSetup();
$this->addAttribute('customer', 'accref', array(
'type' => 'varchar',
'input' => 'text',
'label' => 'Account Reference',
'global' => 1,
'visible' => 1,
'required' => 1,
'user_defined' => 1,
'default' => null,
'visible_on_front' => 1
));
if (version_compare(Mage::getVersion(), '1.6.0', '<=')) {
$customer = Mage::getModel('customer/customer');
$attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId();
$this->addAttributeToSet('customer', $attrSetId, 'General', 'accref');
}
if (version_compare(Mage::getVersion(), '1.4.2', '>=')) {
Mage::getSingleton('eav/config')
->getAttribute('customer', 'accref')
->setData('used_in_forms', array('adminhtml_customer', 'customer_account_create', 'customer_account_edit', 'checkout_register'))
->save();
}
$installer->endSetup();
i have tried many things for example adding
$this->addColumn('accref', array(
'header' => Mage::helper('sales')->__('Account Reference'),
'index' => 'accref',
));
to a copied version of code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php in the _prepareColumns()function.
But nothing is displaying in the sale order grid.
Best Answer
I reckon you need to create a custom module:
app/code/local/My/Module/etc/config.xml
:app/code/local/My/Module/Model/Observer.php
:And obviously:
app/etc/modules/My_Module.xml
: