<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Magento Events Explained and a few Gotchas avoided!</title>
	<atom:link href="http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/</link>
	<description>Notes on Ecommerce Web Development</description>
	<lastBuildDate>Thu, 29 Jul 2010 18:11:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jamaal</title>
		<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1467</link>
		<dc:creator>Jamaal</dc:creator>
		<pubDate>Sun, 27 Jun 2010 04:14:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.aschroder.com/?p=598#comment-1467</guid>
		<description>Thanks Ashley, just sent you an email! 

-jamaal</description>
		<content:encoded><![CDATA[<p>Thanks Ashley, just sent you an email! </p>
<p>-jamaal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley</title>
		<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1466</link>
		<dc:creator>Ashley</dc:creator>
		<pubDate>Sat, 26 Jun 2010 23:59:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.aschroder.com/?p=598#comment-1466</guid>
		<description>The comment had all your formatting stripped - flick me an email and I&#039;ll run an eye over that config.xml - the php code you pasted in doesn&#039;t look quite right either, but that may be related to the comment formatting.</description>
		<content:encoded><![CDATA[<p>The comment had all your formatting stripped &#8211; flick me an email and I&#8217;ll run an eye over that config.xml &#8211; the php code you pasted in doesn&#8217;t look quite right either, but that may be related to the comment formatting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamaal</title>
		<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1462</link>
		<dc:creator>Jamaal</dc:creator>
		<pubDate>Sat, 26 Jun 2010 07:02:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.aschroder.com/?p=598#comment-1462</guid>
		<description>I&#039;m still so confused about this.  I am trying to get checkout_onepage_controller_success_action to work when someone checks out I need to send some SOAP data to someone else.  However it never fires!  


I&#039;ve RTFM&#039;ed so many times and can&#039;t figure out what&#039;s wrong.  


[root@VO12044 etc]# cat config.xml


    
        
            
                0.1.0
            
        
        
            
                MyCompany_MyModule_Helper
            
        
    
    
        
            &lt;!--  --&gt;
                
                
                    
                        model
                        MyCompany_MyModule_Helper_MyFunction
                        setMyFuction
                    
                
                
        
    

&lt;!-- /app/code/local/MyCompany/MyModule/etc/config.xml --&gt;


in app/code/local/MyCompany/MyModule/Helper


[root@VO12044 Helper]# cat MyFunction.php
getEvent()-&gt;getOrder();
     foreach ($order-&gt;getAllItems() as $item) {
        $fname = ($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;orders.txt&#039;);
        $fhandle = fopen($fname,&quot;a&quot;);
        fwrite($fhandle,$item);
        fwrite($fhandle,&quot;BLAH&quot;);
        fclose($fhandle);
        //echo $order-&gt;getStatus();
        //echo $content;

        }

        //$event = $observer-&gt;getEvent();
        //$order = $event-&gt;getOrder();
        //$customer = $event-&gt;getCustomer();

        //file_put_contents($_SERVER[&#039;DOCUMENT_ROOT&#039;].&#039;/_db_backups/array.txt&#039;, serialize(base64_encode($order)));
        //return;
    }
}
// &lt;!-- /app/code/local/MyCompany/MyModule/Helper/MyFunction.php --&gt;


I can&#039;t figure out what im doing wrong.   HALP! 

jamaal@cellyeah.com</description>
		<content:encoded><![CDATA[<p>I&#8217;m still so confused about this.  I am trying to get checkout_onepage_controller_success_action to work when someone checks out I need to send some SOAP data to someone else.  However it never fires!  </p>
<p>I&#8217;ve RTFM&#8217;ed so many times and can&#8217;t figure out what&#8217;s wrong.  </p>
<p>[root@VO12044 etc]# cat config.xml</p>
<p>                0.1.0</p>
<p>                MyCompany_MyModule_Helper</p>
<p>            &lt;!&#8211;  &#8211;&gt;</p>
<p>                        model<br />
                        MyCompany_MyModule_Helper_MyFunction<br />
                        setMyFuction</p>
<p><!-- /app/code/local/MyCompany/MyModule/etc/config.xml --></p>
<p>in app/code/local/MyCompany/MyModule/Helper</p>
<p>[root@VO12044 Helper]# cat MyFunction.php<br />
getEvent()-&gt;getOrder();<br />
     foreach ($order-&gt;getAllItems() as $item) {<br />
        $fname = ($_SERVER['DOCUMENT_ROOT'].&#8217;orders.txt&#8217;);<br />
        $fhandle = fopen($fname,&#8221;a&#8221;);<br />
        fwrite($fhandle,$item);<br />
        fwrite($fhandle,&#8221;BLAH&#8221;);<br />
        fclose($fhandle);<br />
        //echo $order-&gt;getStatus();<br />
        //echo $content;</p>
<p>        }</p>
<p>        //$event = $observer-&gt;getEvent();<br />
        //$order = $event-&gt;getOrder();<br />
        //$customer = $event-&gt;getCustomer();</p>
<p>        //file_put_contents($_SERVER['DOCUMENT_ROOT'].&#8217;/_db_backups/array.txt&#8217;, serialize(base64_encode($order)));<br />
        //return;<br />
    }<br />
}<br />
// <!-- /app/code/local/MyCompany/MyModule/Helper/MyFunction.php --></p>
<p>I can&#8217;t figure out what im doing wrong.   HALP! </p>
<p><a href="mailto:jamaal@cellyeah.com">jamaal@cellyeah.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xer0x</title>
		<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1392</link>
		<dc:creator>xer0x</dc:creator>
		<pubDate>Wed, 02 Jun 2010 20:40:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.aschroder.com/?p=598#comment-1392</guid>
		<description>Thanks this helped a ton</description>
		<content:encoded><![CDATA[<p>Thanks this helped a ton</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashley</title>
		<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1288</link>
		<dc:creator>Ashley</dc:creator>
		<pubDate>Wed, 28 Apr 2010 22:50:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.aschroder.com/?p=598#comment-1288</guid>
		<description>Looking at where that event is fired I&#039;d say you can manipulate the &lt;code&gt;$data&lt;/code&gt; variable in your observer and in doing so control what the parent method then does with the qty updating.
&lt;code&gt;        Mage::dispatchEvent(&#039;checkout_cart_update_items_before&#039;, array(&#039;cart&#039;=&gt;$this, &#039;info&#039;=&gt;$data));&lt;/code&gt;

For example, the code looks for a qty in the itemInfo, &lt;code&gt;$itemInfo[&#039;qty&#039;]&lt;/code&gt; in your observer you could check if the requested new qty is allowable, and if it is not, set it to the old value, which you could get the same way the cart object does;  &lt;code&gt;$item = $this-&gt;getQuote()-&gt;getItemById($itemId);&lt;/code&gt; except $this would be your observer, so you&#039;d want to call that function on the cart parameter to the observer. Does that make sense?

You could even set a session message in your observer like &quot;&lt;em&gt;Sorry the requested quantity of that product is not available&lt;/em&gt;&quot; to be friendly to your users.</description>
		<content:encoded><![CDATA[<p>Looking at where that event is fired I&#8217;d say you can manipulate the <code>$data</code> variable in your observer and in doing so control what the parent method then does with the qty updating.<br />
<code>        Mage::dispatchEvent('checkout_cart_update_items_before', array('cart'=>$this, 'info'=>$data));</code></p>
<p>For example, the code looks for a qty in the itemInfo, <code>$itemInfo['qty']</code> in your observer you could check if the requested new qty is allowable, and if it is not, set it to the old value, which you could get the same way the cart object does;  <code>$item = $this->getQuote()->getItemById($itemId);</code> except $this would be your observer, so you&#8217;d want to call that function on the cart parameter to the observer. Does that make sense?</p>
<p>You could even set a session message in your observer like &#8220;<em>Sorry the requested quantity of that product is not available</em>&#8221; to be friendly to your users.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Dixon</title>
		<link>http://www.aschroder.com/2010/01/magento-events-explained-and-a-few-gotchas-avoided/comment-page-1/#comment-1287</link>
		<dc:creator>Matt Dixon</dc:creator>
		<pubDate>Wed, 28 Apr 2010 22:12:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.aschroder.com/?p=598#comment-1287</guid>
		<description>Hi,

Is it possible to stop the parent method from running from within an event method? or to pass data to the parent event?

Ie. I want to use checkout_cart_update_items_before to check a reserved quantity db field (changing the update quantity if not available) - is that possible or should I just override the core class instead?

Your help would be much appreciated!
Matt</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Is it possible to stop the parent method from running from within an event method? or to pass data to the parent event?</p>
<p>Ie. I want to use checkout_cart_update_items_before to check a reserved quantity db field (changing the update quantity if not available) &#8211; is that possible or should I just override the core class instead?</p>
<p>Your help would be much appreciated!<br />
Matt</p>
]]></content:encoded>
	</item>
</channel>
</rss>
