Magento自定义订单属性

时间:2015-07-20 17:11:53

标签: magento

我正在尝试将自定义属性字段添加到Magento 1.8+数据库的sales_flat_order表中。我是否需要创建新的管理主题?

<?php
$installer = $this;
$installer->startSetup();

$installer->addAttribute("order", "my_custom_input_field", array("type"=>"varchar"));
$installer->addAttribute("quote", "my_custom_input_field", array("type"=>"varchar"));
$installer->endSetup(); 

1 个答案:

答案 0 :(得分:0)

试试这个:

$installer->addAttribute(Mage_Sales_Model_Order::ENTITY, 'THIS_IS_THE_CODE', array(
    'group'         => 'General',
    'type'          => 'varchar',
    'default'       => '0',
    'input'         => 'text',
    'label'         => 'My pretty pretty label',
    'source'        => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => false,
    'user_defined'  =>  false
));

$installer->addAttribute(Mage_Sales_Model_Quote::ENTITY, 'THIS_IS_THE_CODE', array(
    'group'         => 'General',
    'type'          => 'varchar',
    'default'       => '0',
    'input'         => 'text',
    'label'         => 'My pretty pretty label',
    'source'        => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => false,
    'user_defined'  =>  false
));