<?php
class Pixel_Beforeorder_Model_Observer extends Varien_Event_Observer{
/*
** Before save the product user id should be update for current product
*/
public function beforeSaveOrder($observer){
$session = Mage::getSingleton('checkout/session');
foreach ($session->getQuote()->getAllItems() as $item) {
$id = $item->getId();
$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');
$query = "UPDATE sales_flat_quote_item SET act = 0 WHERE item_id = $id";
$writeConnection->query($query);
}
}
}
?>
<?xml version="1.0"?>
<config>
<modules>
<Pixel_Beforeorder>
<version>1.0.0</version>
</Pixel_Beforeorder>
</modules>
<global>
<models>
<pixel_beforeorder>
<class>Pixel_Beforeorder_Model</class>
</pixel_beforeorder>
</models>
<events>
<sales_order_save_after>
<observers>
<pixel_beforeorder>
<type>singleton</type>
<class>pixel_beforeorder/observer</class>
<method>beforeSaveOrder</method>
</pixel_beforeorder>
</observers>
</sales_order_save_after>
</events>
</global>
</config>
class Pixel_Beforeorder_Model_Observer extends Varien_Event_Observer{
/*
** Before save the product user id should be update for current product
*/
public function beforeSaveOrder($observer){
$session = Mage::getSingleton('checkout/session');
foreach ($session->getQuote()->getAllItems() as $item) {
$id = $item->getId();
$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');
$query = "UPDATE sales_flat_quote_item SET act = 0 WHERE item_id = $id";
$writeConnection->query($query);
}
}
}
?>
<?xml version="1.0"?>
<config>
<modules>
<Pixel_Beforeorder>
<version>1.0.0</version>
</Pixel_Beforeorder>
</modules>
<global>
<models>
<pixel_beforeorder>
<class>Pixel_Beforeorder_Model</class>
</pixel_beforeorder>
</models>
<events>
<sales_order_save_after>
<observers>
<pixel_beforeorder>
<type>singleton</type>
<class>pixel_beforeorder/observer</class>
<method>beforeSaveOrder</method>
</pixel_beforeorder>
</observers>
</sales_order_save_after>
</events>
</global>
</config>
1 comments:
commentsNice Blog very useful Thanks....! Such a good information you have posted.
ReplyMagento Development Company: https://www.biztechcs.com/magento-development/