i'm trying add custom field orders. @ moment, found post bellow helped me create such attribute in database: http://fabrizioballiano.net/2011/11/15/create-a-custom-order-attribute-in-magento/
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' => 'int', 'backend_type' => 'text', 'frontend_input' => 'text', 'is_user_defined' => true, 'label' => 'my label', 'visible' => true, 'required' => false, 'user_defined' => true, 'searchable' => true, 'filterable' => true, 'comparable' => true, 'default' => 0 ); $installer->addattribute('order', 'special_attribute', $attribute); $installer->endsetup();
after executing code above , creating several orders, i'm able loop through orders , see default value every order.
the question is, how can store data want in field? how can retrieve such data?
thanks!
add gobal scope in config.xml. set attribute in quote - gets automagically transferred order in quote order conversion process.
<global> ... <fieldsets> <sales_convert_quote> <your_special_attribute> <to_order>*</to_order> </your_special_attribute> </sales_convert_quote> </fieldsets> ... </global>
you can retrieve/set attribute @ time via magic getter/setter e.g.
$quote->getyourspecialattribute() $order->getyourspecialattribute() $quote->setyourspecialattribute()
Comments
Post a Comment