Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
Created March 4, 2014 03:58
Show Gist options
  • Select an option

  • Save ryaan-anthony/9340032 to your computer and use it in GitHub Desktop.

Select an option

Save ryaan-anthony/9340032 to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<config>
<modules>
<Ip_Test>
<version>0.1.0</version>
</Ip_Test>
</modules>
<global>
<models>
<test>
<class>Ip_Test_Model</class>
</test>
</models>
<events>
<sales_order_place_before>
<observers>
<auto_invoice_order>
<type>singleton</type>
<class>test/observer</class>
<method>implementOrderStatus</method>
</auto_invoice_order>
</observers>
</sales_order_place_before>
</events>
</global>
</config>
<?php
class Ip_Test_Model_Observer
{
public function implementOrderStatus(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$orderItems = $order->getAllVisibleItems();
foreach ($orderItems as $item) {
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($item->getProductId());
$stockItem->setQty(123456);
$stockItem->save();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment