Created
March 26, 2016 14:35
-
-
Save the-nerdery-dot-info/ed9c590302dcc941a2ce to your computer and use it in GitHub Desktop.
Magento - adding custom attribute to order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
add this to config.xml to have the attribute automatically | |
transferred to the order from the quote -> order conversion | |
Access the attirbute via magic getters/setters | |
$quote->getYourSpecialAttribute() | |
$order->getYourSpecialAttribute() | |
$quote->setYourSpecialAttribute() | |
--> | |
<global> | |
... | |
<fieldsets> | |
<sales_convert_quote> | |
<your_special_attribute> | |
<to_order>*</to_order> | |
</your_special_attribute> | |
</sales_convert_quote> | |
</fieldsets> | |
... | |
</global> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment