简体   繁体   English

Magento-将自定义属性添加到订单并将此属性添加到集合过滤器

[英]Magento - Add custom attribute to order and add this attribute to collection filter

I follow the method mentioned in this link Magento - Add custom attribute to order like below <global> ... <fieldsets> <sales_convert_quote> <your_special_attribute> <to_order>*</to_order> </your_special_attribute> <sales_convert_quote> </fieldsets> ... </global> to add new custom attribute to order and which is working fine. 我遵循此链接中提到的方法<global> ... <fieldsets> <sales_convert_quote> <your_special_attribute> <to_order>*</to_order> </your_special_attribute> <sales_convert_quote> </fieldsets> ... </global> 向订单添加自定义属性,如下所示: <global> ... <fieldsets> <sales_convert_quote> <your_special_attribute> <to_order>*</to_order> </your_special_attribute> <sales_convert_quote> </fieldsets> ... </global>将新的自定义属性添加到订单,并且效果很好。 But the problem I am facing right now is when I use this attribute in collection filtering then it's not working for the below code.. 但是我现在面临的问题是当我在集合过滤中使用此属性时,它不适用于以下代码。

$orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addAttributeToFilter("your_special_attribute", array("finset"=>'2'))->setOrder('created_at', 'desc');

Adding custom attribute to order involves several steps. 将自定义属性添加到订单涉及几个步骤。 First you have to add a text field to the billing.phtml file. 首先,您必须在billing.phtml文件中添加一个文本字段。 Then save the field in Quote and Order tables and write some event observers to capture quote save, and load events in config.xml file. 然后将该字段保存在Quote和Order表中,并编写一些事件观察器以捕获报价保存,并将事件加载到config.xml文件中。 The 3rd step is to display the field in My Account -> View Order. 第三步是在“我的帐户”->“查看订单”中显示该字段。 Next we need to show our custom field in Admin -> Order -> View Order page. 接下来,我们需要在Admin-> Order-> View Order页面中显示我们的自定义字段。 Every step involves some coding modifications in certain files. 每个步骤都涉及对某些文件的一些编码修改。

If you can specify which step are you facing problem with so that I highlight the files and the changes you need to make there. 如果可以指定您要面对的步骤,以便我突出显示文件和在那里需要进行的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM