#1 add attribute for entites in upgrade script:
<?php
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
/**
* Add 'checkout_process' attribute for entities
*/
$entities = array(
'quote_item',
'order_item'
);
$options = array(
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
'visible' => true,
'required' => false
);
foreach ($entities as $entity) {
$installer->addAttribute($entity, 'checkout_process', $options);
}
$installer->endSetup();
#2 add observer in config.xml
<global>
<fieldsets>
<sales_convert_quote_item>
<checkout_process>
<to_order_item>*</to_order_item>
</checkout_process>
</sales_convert_quote_item>
<sales_convert_order_item>
<checkout_process>
<to_quote_item>*</to_quote_item>
</checkout_process>
</sales_convert_order_item>
</fieldsets>
<sales>
<quote>
<item>
<product_attributes>
<checkout_process />
</product_attributes>
</item>
</quote>
</sales>
<events>
<sales_quote_item_set_product>
<observers>
<sales_quote_item_set_checkoutprocess_handler>
<class>mycheckout/observer</class>
<method>setCheckoutProcessAttribute</method>
</sales_quote_item_set_checkoutprocess_handler>
</observers>
</sales_quote_item_set_product>
</events>
#3 observer function
public function setCheckoutProcessAttribute(Varien_Event_Observer $observer) {
$item = $observer->getQuoteItem();
$product = $observer->getProduct();
$item->setCheckoutProcess($product->getCheckoutProcess());
return $this;
}

本文介绍如何在Magento中通过升级脚本为quote_item和order_item实体添加checkout_process属性,并配置观察者来同步产品属性。
481

被折叠的 条评论
为什么被折叠?



