<global>
<events>
<sales_order_place_after>
<observers>
<sales_order_place_after_observer_change_status>
<type>singleton</type>
<class>mysales/observer</class>
<method>change_status</method>
</sales_order_place_after_observer_change_status>
</observers>
</sales_order_place_after>
</events>
<?php
class Bysoft_Mysales_Model_Observer {
public function change_status($observer) {
$order = $observer->getEvent()->getOrder();
$ordered_items = $order->getAllItems();
$attr_ids = array();
$attr_ids[] = $this->attributeValueExists('checkout_process','Custom products');
$attr_ids[] = $this->attributeValueExists('checkout_process','Global sourcing commodities/pricing');
foreach($ordered_items as $item){
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku());
if (in_array($product->getData('checkout_process') , $attr_ids)) {
$order->setData('state', 'new');
$order->setStatus('new');
$history = $order->addStatusHistoryComment('New Order For Custom and Global Products.', false);
$history->setIsCustomerNotified(false);
$order->save();
return;
}
}
}

本文介绍了一个Magento扩展模块,该模块会在包含特定属性产品的订单完成后自动将订单状态设置为'new',并记录一条状态变更历史。
112

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



