I have created one observer and its called when order placed. sales_order_save_after. Also i have created one sales attribute and try to set value when order placed. but it gives memory allocation error.
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 36 bytes) in D:\xammp\htdocs\magento-1.9.3.0\lib\Zend\Db\Statement\Pdo.php on line 228
Bellow is my code.
config.xml
<events>
<sales_order_save_after> <!-- identifier of the event we want to catch -->
<observers>
<sales_order_save_after_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>customeraffiliate/observer</class> <!-- observers class alias -->
<method>saveAffiliateId</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</sales_order_save_after_handler>
</observers>
</sales_order_save_after>
</events>
Observer.php
class Looxis_Customeraffiliate_Model_Observer
{
public function saveAffiliateId(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getOrder();
if($order->getId())
{
$orderModel = Mage::getModel('sales/order')->load($order->getId());
//print_r($orderModel->getData());
$orderModel->setAffiliateid(2);
//print_r($orderModel->getData());die;
$orderModel->save();
}
}
}
Please help me why its give this error.