Magento 1.6.2.0销售订单自定义属性不起作用

Magento 1.6.2.0销售订单自定义属性不起作用,magento,attributes,Magento,Attributes,我已经花了一整天的时间在这上面了,我想我不能让它工作,因为向订单添加自定义EAV属性的可能性被取消了。 至少,我注意到销售\订单\实体缺失 嗯,我尝试做的是向销售订单添加一个自定义字段。我原以为它的工作方式与分类产品相同,但看起来没有。 我之所以要做这些,是因为我想跟踪谁将产品添加到目录中,并想将特定订单与特定用户(而不是客户)联系起来 它适用于产品,但不适用于订单。我在eav_属性表中有必需的条目 我不知道我是做错了什么,还是这根本不可能? 我还考虑通过创建额外的表来跟踪用户订单与产品之间的关

我已经花了一整天的时间在这上面了,我想我不能让它工作,因为向订单添加自定义EAV属性的可能性被取消了。 至少,我注意到
销售\订单\实体
缺失

嗯,我尝试做的是向销售订单添加一个自定义字段。我原以为它的工作方式与分类产品相同,但看起来没有。 我之所以要做这些,是因为我想跟踪谁将产品添加到目录中,并想将特定订单与特定用户(而不是客户)联系起来

它适用于产品,但不适用于订单。我在eav_属性表中有必需的条目

我不知道我是做错了什么,还是这根本不可能?
我还考虑通过创建额外的表来跟踪用户订单与产品之间的关系来解决这个问题。这需要更多艰苦的工作。

我知道这是一篇老文章,但我在寻找同一问题的答案时遇到了它,所以我想我会分享我的解决方案

让我们以向销售订单添加属性为例

首先,如果查看core/Mage/Sales/etc/config.xml,Magento不再使用EAV实体进行销售

<sales>
      <class>Mage_Sales_Model</class>
      <resourceModel>sales_resource</resourceModel>
</sales>
有了这些信息,您现在应该看到,这只是获取Mage_Sales_Model_Resource_Setup实例并使用有效参数调用其public addAttribute方法的一个例子

向销售订单添加特许经营id属性的代码片段:

$salesResourceSetupModel = Mage::getModel('sales/resource_setup', 'core_setup');

$data=array(
    'type'=>'int',
    'input'=>'text',
    'label'=>'Franchise',
    'global'=> 1,
    'is_required'=>'0',
    'is_comparable'=>'0',
    'is_searchable'=>'0',
    'is_unique'=>'0',
    'is_configurable'=>'0',
    'user_defined'=>'1',
    //whether it should be including in the sales order grid
    'grid'=>1
);

//first param should relate to a key of the protected $_flatEntityTables array
$salesResourceSetupModel->addAttribute('order', 'franchise_id', $data);

我知道这是一篇老文章,但我在寻找同一问题的答案时遇到了它,所以我想我会分享我的解决方案

让我们以向销售订单添加属性为例

首先,如果查看core/Mage/Sales/etc/config.xml,Magento不再使用EAV实体进行销售

<sales>
      <class>Mage_Sales_Model</class>
      <resourceModel>sales_resource</resourceModel>
</sales>
有了这些信息,您现在应该看到,这只是获取Mage_Sales_Model_Resource_Setup实例并使用有效参数调用其public addAttribute方法的一个例子

向销售订单添加特许经营id属性的代码片段:

$salesResourceSetupModel = Mage::getModel('sales/resource_setup', 'core_setup');

$data=array(
    'type'=>'int',
    'input'=>'text',
    'label'=>'Franchise',
    'global'=> 1,
    'is_required'=>'0',
    'is_comparable'=>'0',
    'is_searchable'=>'0',
    'is_unique'=>'0',
    'is_configurable'=>'0',
    'user_defined'=>'1',
    //whether it should be including in the sales order grid
    'grid'=>1
);

//first param should relate to a key of the protected $_flatEntityTables array
$salesResourceSetupModel->addAttribute('order', 'franchise_id', $data);

对于大于1.4.1.0的版本,您必须在sales\u flat\u order表中创建一列。你可以看看这篇文章

对于版本>1.4.1.0,您必须在sales\u flat\u order表中创建一列。你可以看看这篇文章

这与在sales\u flat\u order表中添加新列相同。如果你看一下_addFlatAttribute,它就是这样结束的。这与在sales_flat_order表中添加一个新列是一样的。如果你看一下(u addflattribute),它最终就是这样做的。
$salesResourceSetupModel = Mage::getModel('sales/resource_setup', 'core_setup');

$data=array(
    'type'=>'int',
    'input'=>'text',
    'label'=>'Franchise',
    'global'=> 1,
    'is_required'=>'0',
    'is_comparable'=>'0',
    'is_searchable'=>'0',
    'is_unique'=>'0',
    'is_configurable'=>'0',
    'user_defined'=>'1',
    //whether it should be including in the sales order grid
    'grid'=>1
);

//first param should relate to a key of the protected $_flatEntityTables array
$salesResourceSetupModel->addAttribute('order', 'franchise_id', $data);