change order status for specific product after place order use event

<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;
			}
		}
	}

 

你可能感兴趣的:(change)