<checkout_onepage_controller_success_action>
<observers>
<myPackage_ip_checkoutEvent_observer>
<type>singleton</type>
<class>ip/checkoutEvent_observer</class>
<method>successEvent</method>
</myPackage_ip_checkoutEvent_observer>
</observers>
</checkout_onepage_controller_success_action>
public function successEvent($observer)
{ $event = $observer->getEvent();
$orderIds = $event->getOrderIds();
foreach($orderIds as $order_id){
$order = Mage::getModel( 'sales/order' )->load( $order_id );
$items = $order ->getAllItems();
foreach ( $items as $itemId => $item )
{
$name = $item ->getName();
$unitPrice= $item ->getPrice();
$sku= $item ->getSku();
$ids= $item ->getProductId();
$qty= $item ->getQtyToInvoice();
}
// $qty = $_item['qty'];
// echo $qty."<br/>";
$size_sku = $sku;
$pos = strpos($size_sku,"-");
if($pos<1) {
return $this;
}
$lenght = strlen($size_sku);
$stre = substr($size_sku,$pos+1,$lenght-$pos);
$resource = Mage::getSingleton('core/resource');
$write = $resource->getConnection('core_write');
$productMyIp = (string)Mage::getConfig()->getTablePrefix().'catalog_product_option_type_value';
$sql="update ".$productMyIp. " set sort_order= sort_order-".$qty." where sku = ".$stre;
echo $sql;
$write->query($sql);
//echo "fdsfsd"; exit;
// var_dump($orderIds); exit;
return $this;
}
}