【发布时间】:2012-03-24 18:18:01
【问题描述】:
我已经花了一整天的时间来解决这个问题,但我认为我无法让它工作,因为将自定义 EAV 属性添加到订单的可能性已被删除。
至少,我注意到sales_order_entity 不见了。
好吧,我尝试做的是向销售订单添加一个自定义字段。我认为它与类别产品的工作方式相同,但看起来不行。 我做这一切的总体目的是因为我想跟踪谁将产品添加到目录中,并希望将某个订单与某个用户(而不是客户)关联起来。
public function getDefaultEntities()
{
return array(
'catalog_product' => array(
'entity_model' => 'catalog/product',
'attribute_model' => 'catalog/resource_eav_attribute',
'table' => 'catalog/product',
'additional_attribute_table' => 'catalog/eav_attribute',
'entity_attribute_collection' => 'catalog/product_attribute_collection',
'attributes' => array(
'seller_id' => array(
'group' => 'MyCustom',
'label' => 'Seller ID',
'type' => 'int',
'input' => 'text',
'default' => '0',
'class' => '',
'backend' => '',
'frontend' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => false,
'required' => true,
'user_defined' => true,
'searchable' => true,
'filterable' => true,
'comparable' => false,
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false,
),
),
),
'order' => array(
'entity_model' => 'sales/order',
'table' => 'sales/order',
'increment_model' => 'eav/entity_increment_numeric',
'attributes' => array(
'seller_id' => array(
'group' => 'MyCustom',
'label' => 'Seller ID',
'type' => 'int',
'input' => 'text',
'default' => '0',
'class' => '',
'backend' => '',
'frontend' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => false,
'required' => true,
'user_defined' => true,
'searchable' => true,
'filterable' => true,
'comparable' => false,
'visible_on_front' => false,
'visible_in_advanced_search' => false,
'unique' => false,
),
),
),
);
}
它适用于产品,但不适用于订单。我在 eav_attribute 表中有必填项。
我不知道是我做错了什么还是这不可能? 我还考虑通过创建额外的表来跟踪用户-订单|产品之间的关系来解决这种不同的方法。这将需要更多艰苦的工作。
【问题讨论】:
标签: magento attributes