1

I need to set custom attribute along with order,

This attribute will have random values with each order, I need to show this value on the sales/order grid in admin.

1

Create a custom php file with this code, and put in your root folder of magento.

And run the file by url.

<?php require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup;
$attribute  = array(
        'type'          => 'text',
        'backend_type'  => 'text',
        'frontend_input' => 'text',
        'is_user_defined' => true,
        'label'         => 'Your attribute label',
        'visible'       => true,
        'required'      => false,
        'user_defined'  => false,   
        'searchable'    => false,
        'filterable'    => false,
        'comparable'    => false,
        'default'       => ''
);
$attribute2  = array(
        'type'          => 'text',
        'backend_type'  => 'text',
        'frontend_input' => 'text',
        'is_user_defined' => true,
        'label'         => 'Your attribute label',
        'visible'       => true,
        'required'      => false,
        'user_defined'  => false,   
        'searchable'    => false,
        'filterable'    => false,
        'comparable'    => false,
        'default'       => ''
);
$installer->addAttribute('order', 'placed_order_by', $attribute);
$installer->addAttribute('order', 'related_recurring', $attribute2);
$installer->endSetup();`enter code here`
  • And also this line in your config.xml – Mrunmay Deswandikar Dec 21 '16 at 6:27
  • <fieldsets> <sales_convert_quote> <placed_order_by> <to_order>*</to_order> </placed_order_by> <related_recurring> <to_order>*</to_order> </related_recurring> </sales_convert_quote> </fieldsets> – Mrunmay Deswandikar Dec 21 '16 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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