<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Classy Llama Studios - Specializing in Magento eCommerce, Magento Development, and Magento Design &#187; Magento Development</title>
	<atom:link href="http://classyllama.com/category/development/magento-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://classyllama.com</link>
	<description>Classy Llama Studios is a team of developers, designers and marketers specializing in Magento, Wordpress and Custom Web Application development.</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:32:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Inspecting the contents of Magento models using debug() vs var_dump()</title>
		<link>http://classyllama.com/development/magento-development/inspecting-the-contents-of-magento-models-using-debug-vs-var_dump/</link>
		<comments>http://classyllama.com/development/magento-development/inspecting-the-contents-of-magento-models-using-debug-vs-var_dump/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 16:30:58 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=791</guid>
		<description><![CDATA[When you are developing for Magento, it is often helpful to see the contents of a Model.  A model is a pretty complex object, so when you want to inspect the contents of the model, you generally don&#8217;t want to see all of it&#8217;s properties &#8211; all you&#8217;re really wanting to see is the [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/inspecting-the-contents-of-magento-models-using-debug-vs-var_dump/" title="Inspecting the contents of Magento models using debug() vs var_dump()"><img src="http://classyllama.com/wp-content/uploads/2010/07/var_dump-718x80.png" alt="Method 1 - var_dump" class="feed-image" /></a><p>When you are developing for Magento, it is often helpful to see the contents of a Model.  A model is a pretty complex object, so when you want to inspect the contents of the model, you generally don&#8217;t want to see all of it&#8217;s properties &#8211; all you&#8217;re really wanting to see is the contents of the _data property, which is the array that contains all of the attributes/fields that have been retrieved from the database.</p>
<p>Typically, when inspecting a model, I&#8217;ve used one of the following methods:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p791code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p7914"><td class="code" id="p791code4"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$model</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Method #1: This dumps all of the model's property's, including the _data property.
</span><span style="color: #666666; font-style: italic;"># This results in a lot of superfluous code that I don't need to see.
</span><a href="http://www.php.net/var_dump"><span style="color: #990000;">var_dump</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Method #2: This only logs the data in the _data property.  The problem is, if the _data property contains
</span><span style="color: #666666; font-style: italic;"># any other models, all of the properties of those models will be dumped
</span><a href="http://www.php.net/var_dump"><span style="color: #990000;">var_dump</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I recently came across the ->dump() method that is implemented in the Varien_Object class.  This method recurses into the _data property of a model and returns an array of the values in the _data property, including the _data properties of the child classes.  Here&#8217;s the example code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p791code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p7915"><td class="code" id="p791code5"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Method #3
</span><a href="http://www.php.net/var_dump"><span style="color: #990000;">var_dump</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Note: The Varien_Object class is a class from which MANY classes in Magento extend.  Most notably, all blocks and all data models extend Varien_Object. If you&#8217;ve never looked at the Varien_Object class, I&#8217;d recommend scanning/reading through the methods in that class. If you&#8217;re too lazy to read through the methods, but want to see what the debug() method does, I&#8217;ve included it at the bottom of this post. </p>
<p>Here are three screenshots exemplifying the difference between the different methods (note: the beautifully formatted var_dump output is a feature of the <a href="http://www.xdebug.org/" target="_blank">xdebug</a> php extension):</p>
<p><strong>Method 1:</strong><br />
<div id="attachment_792" class="wp-caption alignnone" style="width: 728px"><a href="http://classyllama.com/wp-content/uploads/2010/07/var_dump.png"><img src="http://classyllama.com/wp-content/uploads/2010/07/var_dump.png" alt="Method 1 - var_dump" title="var_dump" width="718" class="size-large wp-image-792" /></a><p class="wp-caption-text">Method 1 - var_dump</p></div></p>
<p><strong>Method 2:</strong><br />
<div id="attachment_794" class="wp-caption alignnone" style="width: 728px"><a href="http://classyllama.com/wp-content/uploads/2010/07/getData.png"><img src="http://classyllama.com/wp-content/uploads/2010/07/getData.png" alt="Method 2 - getData" title="getData" width="718" class="size-large wp-image-794" /></a><p class="wp-caption-text">Method 2 - getData</p></div></p>
<p><strong>Method 3:</strong><br />
<div id="attachment_796" class="wp-caption alignnone" style="width: 728px"><a href="http://classyllama.com/wp-content/uploads/2010/07/debug.png"><img src="http://classyllama.com/wp-content/uploads/2010/07/debug.png" alt="Method 3 - debug" title="debug" width="718" height="1045" class="size-large wp-image-796" /></a><p class="wp-caption-text">Method 3 - debug</p></div></p>
<p>In case you&#8217;re curious to see how the debug() method works, here&#8217;s the code from the Varien_Object class:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p791code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p7916"><td class="code" id="p791code6"><pre class="php" style="font-family:monospace;">    <span style="color: #009933; font-style: italic;">/**
     * Present object data as string in debug mode
     *
     * @param mixed $data
     * @param array $objects
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> debug<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$objects</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/spl_object_hash"><span style="color: #990000;">spl_object_hash</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$objects</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'*** RECURSION ***'</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000088;">$objects</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$hash</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$debug</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_scalar"><span style="color: #990000;">is_scalar</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$debug</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$debug</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$objects</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span> instanceof Varien_Object<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$debug</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' ('</span><span style="color: #339933;">.</span><a href="http://www.php.net/get_class"><span style="color: #990000;">get_class</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">')'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$objects</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$debug</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I hope this quick tip helps you program with models more effectively!  If you have any questions, feel free to post comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/inspecting-the-contents-of-magento-models-using-debug-vs-var_dump/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enabling Xdebug&#8217;s Exception Handler in Magento</title>
		<link>http://classyllama.com/development/magento-development/enabling-xdebugs-exception-handler-in-magento/</link>
		<comments>http://classyllama.com/development/magento-development/enabling-xdebugs-exception-handler-in-magento/#comments</comments>
		<pubDate>Sat, 08 May 2010 20:22:49 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=558</guid>
		<description><![CDATA[Magento&#8217;s default error and exception handlers provide more information than the default php handlers, as they print out a basic backtrace (example) as opposed to just printing out the file and line number of the error but there are many times when Magento&#8217;s handlers just don&#8217;t cut it; times when you need to see the [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/enabling-xdebugs-exception-handler-in-magento/" title="Enabling Xdebug's Exception Handler in Magento"><img src="http://classyllama.com/wp-content/uploads/2010/05/XdebugException-718x80.png" alt="" class="feed-image" /></a><p>Magento&#8217;s default error and exception handlers provide more information than the default php handlers, as they print out a <em>basic</em> backtrace (<a href="http://classyllama.com/wp-content/uploads/2009/12/Screen-shot-2009-12-30-at-8.10.01-AM.png">example</a>) as opposed to just printing out the file and line number of the error but there are many times when Magento&#8217;s handlers just don&#8217;t cut it; times when you need to see the fully expanded variables that get passed to the functions/methods in the backtrace.</p>
<p>In the <a href="http://classyllama.com/development/magento-development/magento-initial-setup/">Initial Magento Setup Development Tips</a> blog post, I wrote about how Xdebug overrides the default php error handler with a detailed, customizable error backtrace.  I explained how to modify Magento&#8217;s core code so that php errors get handled by Xdebug, not Magento&#8217;s default <em>error</em> handler.  </p>
<p>In this blog post, I&#8217;m going to explain how to modify Magento so that exceptions get handled by Xdebug, not Magento&#8217;s default <em>exception</em> handler.</p>
<p>The Mage::run() method is the method that gets the entire Magento request cycle started, so it makes sense that this is where the exceptions get handled:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p558code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p5589"><td class="code" id="p558code9"><pre class="php" style="font-family:monospace;">    <span style="color: #009933; font-style: italic;">/**
     * Front end main entry point
     *
     * @param string $code
     * @param string $type
     * @param string|array $options
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> run<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'store'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        try <span style="color: #009900;">&#123;</span>
            Varien_Profiler<span style="color: #339933;">::</span><span style="color: #004000;">start</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">setRoot</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_app</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mage_Core_Model_App<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_events</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Varien_Event_Collection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mage_Core_Model_Config<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_app</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'scope_code'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$code</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'scope_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$type</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'options'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$options</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Varien_Profiler<span style="color: #339933;">::</span><span style="color: #004000;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Mage_Core_Model_Session_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: '</span> <span style="color: #339933;">.</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Mage_Core_Model_Store_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getBaseDir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'errors'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'404.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">isInstalled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_isDownloader</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">printException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            try <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">dispatchEvent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage_run_exception'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exception'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/headers_sent"><span style="color: #990000;">headers_sent</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location:'</span> <span style="color: #339933;">.</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'install'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">printException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$ne</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">printException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ne</span><span style="color: #339933;">,</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The problem with the above code is that any exceptions that get thrown by any Magento code get handled by the Mage::printException() method.  What we need to do is run the essential code without wrapping it in any try/catch blocks if the developer mode is enabled from the index.php.  This will result in all exceptions being handled by the Xdebug exception handler.  Here is the resulting code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p558code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p55810"><td class="code" id="p558code10"><pre class="php" style="font-family:monospace;">    <span style="color: #009933; font-style: italic;">/**
     * Front end main entry point
     *
     * @param string $code
     * @param string $type
     * @param string|array $options
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> run<span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'store'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #339933;">=</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getIsDeveloperMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            try <span style="color: #009900;">&#123;</span>
                Varien_Profiler<span style="color: #339933;">::</span><span style="color: #004000;">start</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">setRoot</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_app</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mage_Core_Model_App<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_events</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Varien_Event_Collection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mage_Core_Model_Config<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_app</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">'scope_code'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$code</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'scope_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$type</span><span style="color: #339933;">,</span>
                    <span style="color: #0000ff;">'options'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$options</span><span style="color: #339933;">,</span>
                <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                Varien_Profiler<span style="color: #339933;">::</span><span style="color: #004000;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Mage_Core_Model_Session_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: '</span> <span style="color: #339933;">.</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Mage_Core_Model_Store_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getBaseDir</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'errors'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'404.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">isInstalled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_isDownloader</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">printException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                try <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">dispatchEvent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage_run_exception'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exception'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/headers_sent"><span style="color: #990000;">headers_sent</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location:'</span> <span style="color: #339933;">.</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">getUrl</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'install'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">printException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$ne</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">printException</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ne</span><span style="color: #339933;">,</span> <span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// If we're running in developer mode, we want all exceptions to be handled by the php|xdebug error handler</span>
            Varien_Profiler<span style="color: #339933;">::</span><span style="color: #004000;">start</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">setRoot</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_app</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mage_Core_Model_App<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_events</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Varien_Event_Collection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mage_Core_Model_Config<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_app</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">'scope_code'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$code</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'scope_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$type</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'options'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$options</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            Varien_Profiler<span style="color: #339933;">::</span><span style="color: #004000;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mage'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This code allows Xdebug&#8217;s exception handler to do its magic, resulting in fully detailed exception backtraces like this:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/05/XdebugException.png"><img src="http://classyllama.com/wp-content/uploads/2010/05/XdebugException-718x330.png" alt="XdebugException" title="XdebugException" width="718" height="330" class="aligncenter size-large wp-image-568" /></a></p>
<p>Hopefully this little trick allows you to code Magento more effectively!</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/enabling-xdebugs-exception-handler-in-magento/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Track Inventory for Configurable Products</title>
		<link>http://classyllama.com/development/magento-development/track-inventory-for-configurable-products/</link>
		<comments>http://classyllama.com/development/magento-development/track-inventory-for-configurable-products/#comments</comments>
		<pubDate>Sat, 08 May 2010 19:25:58 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=539</guid>
		<description><![CDATA[We recently had a client who needed to be able to manage inventory for configurable products in Magento.  Since configurable products are intended to merely group simple products together, the ability to track inventory for configurable products is not something that is possible in a vanilla Magento install.
I dug into the Magento codebase to [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/track-inventory-for-configurable-products/" title="Track Inventory for Configurable Products"><img src="http://classyllama.com/wp-content/uploads/2010/05/ConfigurableInventory-718x80.jpg" alt="" class="feed-image" /></a><p>We recently had a client who needed to be able to manage inventory for configurable products in Magento.  Since configurable products are intended to merely group simple products together, the ability to track inventory for configurable products is not something that is possible in a vanilla Magento install.</p>
<p>I dug into the Magento codebase to better understand how inventory is managed for the different product types in Magento.  As you could probably guess, the CatalogInventory module handles all of Magento&#8217;s inventory management.  In side of the /app/code/core/Mage/CatalogInventory/etc/config.xml file, you&#8217;ll find the following section of xml contained in the global tag:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p539code12'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p53912"><td class="code" id="p539code12"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;simple<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;is_qty<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/is_qty<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/simple<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;virtual<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;is_qty<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/is_qty<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/virtual<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configurable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stock_indexer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cataloginventory/indexer_stock_configurable<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stock_indexer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configurable<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;grouped<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stock_indexer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cataloginventory/indexer_stock_grouped<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stock_indexer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/grouped<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/product<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>This section of xml is used by Mage_CatalogInventory_Helper_Data::getIsQtyTypeIds method to determine if a certain product type &#8220;qualifies&#8221; for inventory tracking.  It is also used to indicate if there is a custom resource model that needs to be used to calculate the stock availability for a certain product type. </p>
<p>The beautiful thing about the way Magento handles the configuration xml is that we can create xml nodes that mirror the structure of the above xml in a config.xml file in a custom module &#8211; this allows us to change pretty much any configuration value without having to touch any of the config.xml files of core Magento modules.  Magento will then merge the xml nodes from both config.xml files.  Since custom modules are loaded after core modules, any nodes that override default Magento nodes will take precedence.</p>
<p>I created a <a href="http://classyllama.com/wp-content/uploads/2010/05/ConfigurableInventory.tgz" target="_blank">small module</a> that enables inventory tracking for configurable products.  The following sections in Magento are overridden by this module:</p>
<ul>
<li>app/code/core/Mage/CatalogInventory/Model/Observer.php (lines 365 &#8211; 405)</li>
<li>app/code/core/Mage/CatalogInventory/etc/config.xml (line 202)</li>
<li>app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml (line 55)</li>
</ul>
<p>You can download this module <a href="http://classyllama.com/wp-content/uploads/2010/05/ConfigurableInventory.tgz" target="_blank">here</a>.  All you need to do to install the module is to copy the app folder into your Magento install folder.  Note:</p>
<ul>
<li>There are two different ways of tracking inventory for configurable products.  Read the comments in the app/code/local/CLS/ConfigurableInventory/etc/config.xml file for details.</li>
<li>This module is built for Magento 1.4.0.1.  It&#8217;ll likely work on older versions of Magento, but I&#8217;ve only tested it on 1.4.0.1</li>
</ul>
<blockquote><p>UPDATE (5/12/10):  After working with this test module on a dev site, it looks like the $item->getProduct() method call on line 21 in the CLS_ConfigurableInventory_Model_CatalogInventory_Observer class actually isn&#8217;t returning a product model for all order items.  This is something that I&#8217;ll be debugging once we actually implement this test code in a project.  I&#8217;ll try to post an update here when we do that.</p></blockquote>
<p>I&#8217;d love to hear from any of you that end up implementing this code on your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/track-inventory-for-configurable-products/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Disabling Javascript Merging in Magento</title>
		<link>http://classyllama.com/development/magento-development/disabling-javascript-merging-in-magento/</link>
		<comments>http://classyllama.com/development/magento-development/disabling-javascript-merging-in-magento/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 20:39:14 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=481</guid>
		<description><![CDATA[If you have ever written Javascript for Magento, you have probably been frustrated by the fact that Magento merges all of its JS files before outputting them to the frontend.  This makes debugging difficult for a few of reasons:

It makes it more difficult to see if your JS file is even being loaded
When Firebug [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/disabling-javascript-merging-in-magento/" title="Disabling Javascript Merging in Magento"><img src="http://classyllama.com/wp-content/uploads/2010/03/Screen-shot-2010-03-28-at-6.09.51-PM-718x80.png" alt="" class="feed-image" /></a><p>If you have ever written Javascript for Magento, you have probably been frustrated by the fact that Magento merges all of its JS files before outputting them to the frontend.  This makes debugging difficult for a few of reasons:</p>
<ul>
<li>It makes it more difficult to see if your JS file is even being loaded</li>
<li>When Firebug (or your JS debugger of choice) logs errors to the console, it&#8217;s impossible to match up the line numbers Firebug reports with the line numbers in the file</li>
<li>If you want to use Firebug&#8217;s <a href="http://getfirebug.com/javascript">debugging or profiling tools</a>, you&#8217;re greatly impaired by having all the JS in one file.
</ul>
<p>A few months ago, one of our developers stumbled across the ability to disable the JS merging in Magento:  Go to System > Preferences > Developer > Javascript Settings tab > Set &#8220;Merge JavaScript Files&#8221; to &#8220;No&#8221;.</p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/03/Screen-shot-2010-03-28-at-6.09.51-PM.png"><img src="http://classyllama.com/wp-content/uploads/2010/03/Screen-shot-2010-03-28-at-6.09.51-PM.png" alt="DisableJsMerging" title="DisableJsMerging" width="718" height="124" class="alignleft size-full wp-image-486" /></a></p>
<p>I hope this helps in your Magento Javascript debugging!</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/disabling-javascript-merging-in-magento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Viewing Error Backtraces for Ambiguous Error Messages</title>
		<link>http://classyllama.com/development/magento-development/viewing-error-backtraces-for-ambiguous-error-messages/</link>
		<comments>http://classyllama.com/development/magento-development/viewing-error-backtraces-for-ambiguous-error-messages/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 21:10:43 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=472</guid>
		<description><![CDATA[There are many times when working with the Magento frontend that I get very ambiguous error message.  Here is a screenshot of the type of error I&#8217;m talking about:


I usually just search the entire codebase for the error message code, locate the place where the exception is getting caught, and then temporarily modify the [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/viewing-error-backtraces-for-ambiguous-error-messages/" title="Viewing Error Backtraces for Ambiguous Error Messages"><img src="http://classyllama.com/wp-content/uploads/2010/03/Screen-shot-2010-03-19-at-3.55.53-PM-718x80.png" alt="" class="feed-image" /></a><p>There are many times when working with the Magento frontend that I get very ambiguous error message.  Here is a screenshot of the type of error I&#8217;m talking about:<br />
<a href="http://classyllama.com/wp-content/uploads/2010/03/Screen-shot-2010-03-19-at-3.55.53-PM1.png"><img src="http://classyllama.com/wp-content/uploads/2010/03/Screen-shot-2010-03-19-at-3.55.53-PM1.png" alt="Error Message" title="Error Message" width="718" height="168" class="alignleft size-full wp-image-475" /></a>
</p>
<p>I usually just search the entire codebase for the error message code, locate the place where the exception is getting caught, and then temporarily modify the code to Mage::log() the following data: $e->getMessage(), $e->getTraceAsString(), etc&#8230;</p>
<p>I just came across an exception handler in the Mage_Checkout_MultishippingController class that passed the generic exception message as well as the Exception class itself to Mage::getSingleton(&#8217;checkout/session&#8217;)->addException(). Here&#8217;s the code (from line 219 of the containing file):</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p472code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p47214"><td class="code" id="p472code14"><pre class="php" style="font-family:monospace;">        catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'checkout/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addException</span><span style="color: #009900;">&#40;</span>
                <span style="color: #000088;">$e</span><span style="color: #339933;">,</span>
                Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'checkout'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Data saving problem'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_redirect<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*/*/addresses'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I dug into the Mage::getSingleton(&#8217;checkout/session&#8217;)->addException() class and realized that it logged the exception code to the var/logs/exception.log file (it only logs the exception if logging is enabled in System > Preferences > Developer).  This means that instead of locating and hacking up core files to see exceptions that are thrown, in a lot of cases, you can just monitor the contents of the exception.log file.</p>
<p>If you&#8217;re developing on a Mac machine, you can monitor the contents of the exception.log file using the Console app.  If you&#8217;re on a Linux box, you can use &#8220;tail -f var/log/exception.log&#8221; to monitor the contents of this file.</p>
<p>Hopefully this helps you in your debugging efforts!</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/viewing-error-backtraces-for-ambiguous-error-messages/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Editing Magento&#8217;s Footer Links</title>
		<link>http://classyllama.com/development/magento-development/editing-magentos-footer-links/</link>
		<comments>http://classyllama.com/development/magento-development/editing-magentos-footer-links/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 20:07:17 +0000</pubDate>
		<dc:creator>kkirchner</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=426</guid>
		<description><![CDATA[To follow up on our post about editing Magento&#8217;s top links, I thought I might as well write an article about editing the footer links while I&#8217;m at it.  I&#8217;d recommend reading our post about using a local.xml file before getting started on this post.  This post might not make much sense until you read [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/editing-magentos-footer-links/" title="Editing Magento's Footer Links"><img src="http://classyllama.com/wp-content/uploads/2010/03/BottomLinks2.jpg" alt="Editing Footer Links" class="feed-image" /></a><p>To follow up on <a title="Editing Magento's Top Links" href="http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/">our post about editing Magento&#8217;s top links</a>, I thought I might as well write an article about editing the footer links while I&#8217;m at it.  I&#8217;d recommend reading <a title="The Better Way to Modify Magento" href="http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/" target="_blank">our post about using a local.xml file</a> before getting started on this post.  This post might not make much sense until you read it.<em> [NOTE: This specific example assumes you are using the blank theme. Layout handles may differ from theme to theme.]</em></p>
<p><strong>In local.xml:</strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p426code16'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p42616"><td class="code" id="p426code16"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;footer_links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #808080; font-style: italic;">&lt;!-- Add custom links. Pretty self-explanatory.</span>
<span style="color: #808080; font-style: italic;">            Dig into app/code/core/Mage/Page/Block/Template/Links.php for more info --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addLink&quot;</span> <span style="color: #000066;">translate</span>=<span style="color: #ff0000;">&quot;label title&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>About Us<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>about<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  <span style="color: #808080; font-style: italic;">&lt;!-- can use a full url if not using urlParams below --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>About Us<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prepare<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prepare<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!-- set true if adding base url param --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;urlParams</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;core/url/getHomeUrl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- base url - thanks @Russ! --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;position<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/position<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;liParams</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;aParams<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>class=&quot;top-link-about-us&quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/aParams<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beforeText<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/beforeText<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;afterText<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/afterText<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #808080; font-style: italic;">&lt;!-- Remove 'Site Map' Link - Default Position: 10</span>
<span style="color: #808080; font-style: italic;">            Original link adding in catalog.xml --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;catalog/map/getCategoryUrl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #808080; font-style: italic;">&lt;!-- Remove 'Search Terms' Link - Default Position: 20</span>
<span style="color: #808080; font-style: italic;">            Original link adding in catalogsearch.xml--&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;catalogsearch/getSearchTermUrl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #808080; font-style: italic;">&lt;!-- Remove 'Advanced Search' - Default Position: 30</span>
<span style="color: #808080; font-style: italic;">            Original link adding in catalogsearch.xml--&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;catalogsearch/getAdvancedSearchUrl&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #808080; font-style: italic;">&lt;!-- Remove 'Contact Us' link - Original link in contacts.xml</span>
<span style="color: #808080; font-style: italic;">            &lt;!-- Best bet to go to Magento's Admin &gt; System &gt; Configuration &gt; (left sidebar) Contacts</span>
<span style="color: #808080; font-style: italic;">            &gt; Contact Us Enabled = NO --&gt;</span>
            <span style="color: #808080; font-style: italic;">&lt;!-- You can pass the full url, which is a hassle if you have dev and stage sites --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://YOUR_SITE.com/contacts/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #808080; font-style: italic;">&lt;!-- see comments below for making a custom helper to remove contacts link</span>
<span style="color: #808080; font-style: italic;">            no matter what your base url is  --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #808080; font-style: italic;">&lt;!-- By default, Magento sets a static footer block. Find it in the admin under</span>
<span style="color: #808080; font-style: italic;">        CMS &gt; Static Blocks.</span>
<span style="color: #808080; font-style: italic;">	&lt;reference name=&quot;footer&quot;&gt;</span>
<span style="color: #808080; font-style: italic;">            &lt;!-- Remove Magento's default static block and use the 'addLink' method above</span>
<span style="color: #808080; font-style: italic;">            to add your custom and inline links.  I use the 'unsetChild' method as often as</span>
<span style="color: #808080; font-style: italic;">            possible as opposed using the more final &lt;remove name=&quot;cms_footer_links&quot;/&gt;</span>
<span style="color: #808080; font-style: italic;">            just in case I want to add the block somewhere else --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>cms_footer_links<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #808080; font-style: italic;">&lt;!-- Remove all the other Magento links - &quot;Site Map, Search Terms, Advanced Search, and</span>
<span style="color: #808080; font-style: italic;">            Contact Us&quot; --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>footer_links<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!-- Magento 1.4.x --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>If all else fails, you can edit template/page/template/links.phtml. However, if you can make all your changes in local.xml, your life will be so much easier when it comes to upgrading Magento and making future edits.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/editing-magentos-footer-links/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Editing Magento&#8217;s Top Links (The Better Way)</title>
		<link>http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/</link>
		<comments>http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 20:23:04 +0000</pubDate>
		<dc:creator>kkirchner</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=328</guid>
		<description><![CDATA[You might need to read the post about using a local.xml file before this post makes much sense.
We offer all our clients a completely customized design from scratch, which means changing anything &#8211; including those annoying defaulted top links.  This post will show you how to edit your top links (without editing core layout files [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/" title="Editing Magento's Top Links (The Better Way)"><img src="http://classyllama.com/wp-content/uploads/2010/02/TopLinks2.jpg" alt="" class="feed-image" /></a><p>You might need to read the <a href="http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/" target="_blank">post about using a local.xml file</a> before this post makes much sense.</p>
<p>We offer all our clients a completely customized design from scratch, which means changing anything &#8211; including those annoying defaulted top links.  This post will show you how to edit your top links (without editing core layout files which may change when you update Magento) by utilizing a <a href="http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/" target="_blank">local.xml file</a>. You can even add your own custom links without touching any template files! <em>[NOTE: This specific example assumes you are using the <a href="http://www.magentocommerce.com/extension/reviews/module/518" target="_blank">blank theme</a>. Layout handles may differ from theme to theme.]</em></p>
<p><em>ADDITION: Check out the blog post about <a href="http://classyllama.com/development/magento-development/editing-magentos-footer-links/" target="_blank">editing Magento&#8217;s footer links</a></em></p>
<p><b>In local.xml:</b></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p328code18'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p32818"><td class="code" id="p328code18"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;root&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;top.links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                <span style="color: #808080; font-style: italic;">&lt;!-- Add custom links. Pretty self-explanatory.</span>
<span style="color: #808080; font-style: italic;">                Dig into app/code/core/Mage/Page/Block/Template/Links.php for more info --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addLink&quot;</span> <span style="color: #000066;">translate</span>=<span style="color: #ff0000;">&quot;label title&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>About Us<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>about<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  <span style="color: #808080; font-style: italic;">&lt;!-- can use full url also --&gt;</span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>About Us<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prepare<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prepare<span style="color: #000000; font-weight: bold;">&gt;</span></span></span> <span style="color: #808080; font-style: italic;">&lt;!-- set true if adding base url param --&gt;</span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;urlParams</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;core/url/getHomeUrl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- base url - thanks @Russ! --&gt;</span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;position<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/position<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;liParams</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;aParams<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>class=&quot;top-link-about-us&quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/aParams<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beforeText<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/beforeText<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;afterText<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/afterText<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- Removes 'My Account' link - Default position: 10 --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;customer/getAccountUrl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- Removes 'Wishlist' link - Default position: 20 --&gt;</span>
                <span style="color: #808080; font-style: italic;">&lt;!-- for Magento 1.3.x --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;wishlist/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- for Magento 1.4.x --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;wishlist_link&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- Removes 'My Cart' AND 'Checkout' links</span>
<span style="color: #808080; font-style: italic;">                Default position: 40 and 50 respectively --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;checkout_cart_link&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- To re-add 'My Cart' or 'Checkout' after removing both --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;checkout/links&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;checkout_cart_link_custom&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addCartLink&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addCheckoutLink&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customer_logged_out<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- Removes 'Log In' link - Default position: 60 --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;top.links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;customer/getLoginUrl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/customer_logged_out<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;customer_logged_in<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- Removes 'Log Out' link - Default position: 60 --&gt;</span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;top.links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeLinkByUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;url</span> <span style="color: #000066;">helper</span>=<span style="color: #ff0000;">&quot;customer/getLogoutUrl&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/customer_logged_in<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>If you <em>absolutely</em> cannot find a way to customize your top links using these methods, you can edit the /template/page/template/links.phtml</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>The Better Way to Modify Magento Layouts</title>
		<link>http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/</link>
		<comments>http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 14:10:45 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=353</guid>
		<description><![CDATA[In this article, I&#8217;m going to be covering what I believe to be a very effective way of modifying the layout of any Magento theme.  
For several of the first Magento themes I built, I copied the layout files from the default or blank theme into the custom theme layout folder.  I would [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/" title="The Better Way to Modify Magento Layouts"><img src="http://classyllama.com/wp-content/uploads/2010/02/Screen-shot-2010-02-23-at-8.11.32-AM.png" alt="" class="feed-image" /></a><p>In this article, I&#8217;m going to be covering what I believe to be a very effective way of modifying the layout of any Magento theme.  </p>
<p>For several of the first Magento themes I built, I copied the layout files from the default or blank theme into the custom theme layout folder.  I would then modify the layout files directly, editing or commenting out content in files like: catalog.xml, page.xml, checkout.xml, etc&#8230;  I never liked editing these files directly, as I knew that when it came time to upgrade to a newer version of Magento that had upgraded the layout files, I&#8217;d have to merge the changes into the new layout files.  </p>
<p>One day, I was digging through the Magento code relating to layout files and discovered a bit of code that made me realize that it was possible to just place a local.xml file in my custom theme&#8217;s layout folder and have it loaded automatically by Magento.  (this code is on line 283 in /app/code/core/Mage/Core/Model/Layout/Update.php in the fetchFileLayoutUpdates() method).  </p>
<p>Due to Magento&#8217;s brilliant <reference> tags, it&#8217;s possible to do just about anything you want without having to edit any of the default layout files. </p>
<p>Before delving into the code, let&#8217;s look at the advantages/disadvantages of this method:</p>
<h3>Advantages</h3>
<ul>
<li>Allows you to upgrade themes without having to merge in changes</li>
<li>All custom layout changes are centralized, allowing developers to more easily make changes to custom theme elements</li>
</ul>
<h3>Disadvantages</h3>
<ul>
<li>At first, it&#8217;s slower to use this method than hacking up the standard layout files directly</li>
<li>You will have one more place to look where the site might be pulling code (template phtmls, standard layout files, admin layout updates, AND local.xml)</li>
</ul>
<p>Here is the slimmed down, commented local.xml from one of our recent projects:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p353code20'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p35320"><td class="code" id="p353code20"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;0.1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;head&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #808080; font-style: italic;">&lt;!-- Magento looks in /skin/frontend/&lt;INTERFACE&gt;/&lt;THEME&gt;/js/buyprinting.js</span>
<span style="color: #808080; font-style: italic;">		for this file --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addItem&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>skin_js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>js/buyprinting.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- This removes the item that was set in the page.xml file --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;removeItem&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>skin_js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>js/iehover-fix.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #808080; font-style: italic;">&lt;!-- Magento looks in /js/prototype/element.storage.js for this file --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addJs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>prototype/element.storage.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;addCss&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>css/buyprinting.css<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stylesheet<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- This adds a CMS block that can be called from the template file</span>
<span style="color: #808080; font-style: italic;">        associated with the header block. --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cms/block&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;cms_quick_help&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setBlockId&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>quick_help<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #808080; font-style: italic;">&lt;!-- The remove tag removes the blocks with the specified name from the layout --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;top.menu&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;store_language&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;breadcrumbs&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;top.nav&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;catalog.topnav&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;left.newsletter&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;left.permanent.callout&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;catalogsearch.leftnav&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
        <span style="color: #808080; font-style: italic;">&lt;!-- When you use the remove tag, it removes any blocks with the specified name from</span>
<span style="color: #808080; font-style: italic;">            the entire layout, regardless of the context. So, if I remove right.newsletter in</span>
<span style="color: #808080; font-style: italic;">            the &lt;default&gt; context and that name is used in say the &lt;catalog_product_view&gt; context,</span>
<span style="color: #808080; font-style: italic;">            then both blocks will be removed.  Because remove operates on the global context,</span>
<span style="color: #808080; font-style: italic;">            you can only remove an element once.  Since &lt;remove name=&quot;right.newsletter&quot; /&gt; is</span>
<span style="color: #808080; font-style: italic;">            being called in catalogsearch.xml, we have to unset it, or else we'll get an error.</span>
&nbsp;
<span style="color: #808080; font-style: italic;">            The line below only unsets the block from the parent's context, not the global</span>
<span style="color: #808080; font-style: italic;">            layout context --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>right.newsletter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;right&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- Some blocks have to be removed using remove, others via unsetChild.</span>
<span style="color: #808080; font-style: italic;">            I've not spent the time digging into the code to figure out why --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;right.permanent.callout&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;catalog.compare.sidebar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;left.reports.product.viewed&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sale.reorder.sidebar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>wishlist_sidebar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>right.reports.product.viewed<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;cart_sidebar&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- CATALOG PAGES --&gt;</span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;catalog_product_view<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><span style="color: #808080; font-style: italic;">&lt;!-- 2columns-right --&gt;</span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;root&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setTemplate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>page/2columns-left.phtml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/template<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;product.info&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;cms/block&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;cms_product_info_tabs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setBlockId&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>product_info_tabs<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block_id<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;catalog/product_view&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;product.clone_prices&quot;</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;prices&quot;</span> <span style="color: #000066;">template</span>=<span style="color: #ff0000;">&quot;catalog/product/view/price_clone.phtml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>tierprices<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>addto<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;remove</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;addto&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;product.info.options.wrapper.bottom&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;unsetChild&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>product.tierprices<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/catalog_product_view<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>I hope with article has given you some direction as to how you can improve you Magento theming skills.  If you have any additional tips/comments on coding layouts, please suggest them in the comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/feed/</wfw:commentRss>
		<slash:comments>87</slash:comments>
		</item>
		<item>
		<title>The Smart Method of Loading Collections</title>
		<link>http://classyllama.com/development/magento-development/the-smart-method-of-loading-collections/</link>
		<comments>http://classyllama.com/development/magento-development/the-smart-method-of-loading-collections/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 20:15:00 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=315</guid>
		<description><![CDATA[One fairly unknown feature of Magento collections is that you actually don&#8217;t have to call ->load() on a collection before being able to access the items in the collection.  So you can do this:

?View Code PHP$orders = Mage::getResourceModel&#40;'sales/order_collection'&#41;-&#62;addAttributeToSelect&#40;'*'&#41;;
# The load method is not necessary, as iterating through a collection automatically loads it, if it [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/the-smart-method-of-loading-collections/" title="The Smart Method of Loading Collections"><img src="http://classyllama.com/wp-content/uploads/2010/02/Screen-shot-2010-02-10-at-2.23.33-PM.png" alt="" class="feed-image" /></a><p>One fairly unknown feature of Magento collections is that you actually don&#8217;t have to call ->load() on a collection before being able to access the items in the collection.  So you can do this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p315code23'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p31523"><td class="code" id="p315code23"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$orders</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getResourceModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sales/order_collection'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttributeToSelect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;"># The load method is not necessary, as iterating through a collection automatically loads it, if it hasn't already been loaded.
</span><span style="color: #666666; font-style: italic;"># $orders-&gt;load();
</span><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$orders</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$order</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Order Id: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$order</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The base Varien_Data_Collection class implements the IteratorAggregate (http://php.net/manual/en/class.iteratoraggregate.php) interface which extends the Traversable (http://www.php.net/manual/en/class.traversable.php) interface.  When a class extends the Traversable interface, it guarantees that that class can be iterated through using foreach().  When foreach is called on a collection, it calls the getIterator() method in the Varien_Data_Collection class and uses the value returned from that method as the value that the foreach iterates through.  This is the getIterator() method:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p315code24'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p31524"><td class="code" id="p315code24"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getIterator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_items<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This auto-loading functionality works for both EAV and flat-table collections.</p>
<p>As you can see, a collection ensures that it is loaded before running through a foreach loop. Note: collections can only be loaded once per instantiation.  If you want to reload a collection, you have to call the clear() method, and then reset the select and filters before calling the load() method again.</p>
<p>Knowing that collections function in this way allows you to write code without explicit calls to load().  This ultimately should result in more flexible code.  You can have a method in a block that loads a collection.  That collection can then either be called by a template file and iterated through, or you can have another method that loads the collection from the first method, and then adds additional selects/filters to it.  This practice of not explicitly calling the load() results in more flexible and reusable code.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/the-smart-method-of-loading-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving the Value of a Specific Attribute from a Model</title>
		<link>http://classyllama.com/development/magento-development/saving-the-value-of-a-specific-attribute-from-a-model/</link>
		<comments>http://classyllama.com/development/magento-development/saving-the-value-of-a-specific-attribute-from-a-model/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 16:46:29 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=303</guid>
		<description><![CDATA[How to save the value of a specific attribute of an EAV model.]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/saving-the-value-of-a-specific-attribute-from-a-model/" title="Saving the Value of a Specific Attribute from a Model"><img src="http://classyllama.com/wp-content/uploads/2010/02/Screen-shot-2010-02-10-at-10.47.12-AM.png" alt="" class="feed-image" /></a><p>In Magento, it&#8217;s very easy to save all the data in a model by running $model->save();. (Note: In this blog post, model refers to an EAV model, not a flat resource model)  This saves all the attributes for the model to their respective attribute tables.  There are times when saving the value of just one of the model attributes is desirable.  A couple cases where you&#8217;d want to do this:</p>
<ul>
<li>You&#8217;ve been passed a model from an event, and you aren&#8217;t sure if the data in that model can be safely saved.</li>
<li>You are saving many models and want to make your save operations as efficient as possible</li>
</ul>
<p>Here is how you&#8217;d save just one attribute of a product model:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p303code25'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p30325"><td class="code" id="p303code25"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$product</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Some Random Name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$product</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/saving-the-value-of-a-specific-attribute-from-a-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add Magento Admin Account Using MySQL Script</title>
		<link>http://classyllama.com/development/magento-development/add-magento-admin-account-using-mysql-script/</link>
		<comments>http://classyllama.com/development/magento-development/add-magento-admin-account-using-mysql-script/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 15:13:11 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=236</guid>
		<description><![CDATA[Note: this script works on Magento CE 1.3.2.4 and 1.4.0.* but does not work in the Magento Enterprise Edition
As a Magento development company, we have a number of designers, developers, and project managers that need admin access to the sites that we build.  As opposed to using one global admin account for our entire [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/add-magento-admin-account-using-mysql-script/" title="Add Magento Admin Account Using MySQL Script"><img src="http://classyllama.com/wp-content/uploads/2010/01/MagentoAdmin.jpg" alt="" class="feed-image" /></a><blockquote><p>Note: this script works on Magento CE 1.3.2.4 and 1.4.0.* but does not work in the Magento Enterprise Edition</p></blockquote>
<p>As a Magento development company, we have a number of designers, developers, and project managers that need admin access to the sites that we build.  As opposed to using one global admin account for our entire team, we believe it to be a much better practice to assign individual admin accounts to each team member who is going to be working on a project.</p>
<p>One of our developers, Matt Johnson, has developed a script to allow us to easily add an admin user to a Magento installation.  Each member on our team that needs Magento admin access has a sql file that adds their admin account to Magento.  When we start a new project, we run the sql script for the members of our team that are going to need access to the server.  I hope you&#8217;ll find this snippet useful.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p236code27'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p23627"><td class="code" id="p236code27"><pre class="mysql" style="font-family:monospace;"><span style="color: #808000; font-style: italic;">/* This is an example SQL script.
You should replace all the UPPERCASED variables.
The &lt;USERNAME&gt; variable can only be alphanumeric characters, and probably underscores (haven't tested)
&nbsp;
You can either generate a password hash using the PHP code below,
or you can grab a password hash from the admin_user table from an
existing Magento install for which you know the admin password.
*/</span>
&nbsp;
<span style="color: #808000; font-style: italic;">/* Use the following PHP script to generate a salted password hash. You can also use a straight md5 hash, but it's much more easily brute-forced
&lt;?php $password = 'PASSWORD'; $salt = 'GF'; echo $hash = md5($salt.$password).':'.$salt; ?&gt;
*/</span>
&nbsp;
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">insert</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">into</span></a> admin_user
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a>
<span style="color: #FF00FF;">&#40;</span><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/group-by-functions-and-modifiers.html"><span style="color: #000099;">max</span></a><span style="color: #FF00FF;">&#40;</span>user_id<span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099;">+</span> <span style="color: #008080;">1</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">from</span></a> admin_user<span style="color: #FF00FF;">&#41;</span> user_id<span style="color: #000033;">,</span>
<span style="color: #008000;">'FIRST NAME'</span> first_name<span style="color: #000033;">,</span>
<span style="color: #008000;">'LAST NAME'</span> last_name<span style="color: #000033;">,</span>
<span style="color: #008000;">'EMAIL'</span> email<span style="color: #000033;">,</span>
<span style="color: #008000;">'USERNAME'</span> username<span style="color: #000033;">,</span>
<span style="color: #008000;">'HASH EXAMPLE: 178f29c8e4c6c801db90cd171e3b2b53:in'</span> <a href="http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html"><span style="color: #000099;">password</span></a><span style="color: #000033;">,</span> <span style="color: #808000; font-style: italic;">/* You can replace this value with an md5 hash */</span>
<a href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html"><span style="color: #000099;">now</span></a><span style="color: #FF00FF;">&#40;</span><span style="color: #FF00FF;">&#41;</span> created<span style="color: #000033;">,</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> modified<span style="color: #000033;">,</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">NULL</span></a> logdate<span style="color: #000033;">,</span>
<span style="color: #008080;">0</span> lognum<span style="color: #000033;">,</span>
<span style="color: #008080;">0</span> reload_acl_flag<span style="color: #000033;">,</span>
<span style="color: #008080;">1</span> is_active<span style="color: #000033;">,</span>
<span style="color: #FF00FF;">&#40;</span><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/group-by-functions-and-modifiers.html"><span style="color: #000099;">max</span></a><span style="color: #FF00FF;">&#40;</span>extra<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">from</span></a> admin_user <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">where</span></a> extra <a href="http://dev.mysql.com/doc/refman/5.1/en/non-typed-operators.html"><span style="color: #CC0099; font-weight: bold;">is not</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=NULL&amp;lr=lang_en"><span style="color: #9900FF; font-weight: bold;">null</span></a><span style="color: #FF00FF;">&#41;</span> extra<span style="color: #000033;">;</span>
&nbsp;
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">insert</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">into</span></a> admin_role
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a>
<span style="color: #FF00FF;">&#40;</span><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a> <a href="http://dev.mysql.com/doc/refman/5.1/en/group-by-functions-and-modifiers.html"><span style="color: #000099;">max</span></a><span style="color: #FF00FF;">&#40;</span>role_id<span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099;">+</span> <span style="color: #008080;">1</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">from</span></a> admin_role<span style="color: #FF00FF;">&#41;</span> role_id<span style="color: #000033;">,</span>
<span style="color: #FF00FF;">&#40;</span><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a> role_id <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">from</span></a> admin_role <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">where</span></a> role_name <span style="color: #CC0099;">=</span> <span style="color: #008000;">'Administrators'</span><span style="color: #FF00FF;">&#41;</span> parent_id<span style="color: #000033;">,</span>
<span style="color: #008080;">2</span> tree_level<span style="color: #000033;">,</span>
<span style="color: #008080;">0</span> sort_order<span style="color: #000033;">,</span>
<span style="color: #008000;">'U'</span> role_type<span style="color: #000033;">,</span>
<span style="color: #FF00FF;">&#40;</span><a href="http://search.mysql.com/search?site=refman-51&amp;q=SELECT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">select</span></a> user_id <a href="http://search.mysql.com/search?site=refman-51&amp;q=FROM&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">from</span></a> admin_user <a href="http://search.mysql.com/search?site=refman-51&amp;q=WHERE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">where</span></a> username <span style="color: #CC0099;">=</span> <span style="color: #008000;">'USERNAME'</span><span style="color: #FF00FF;">&#41;</span> user_id<span style="color: #000033;">,</span>
<span style="color: #008000;">'USERNAME'</span> role_name</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/add-magento-admin-account-using-mysql-script/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Enable/disable template/block Hints Using MySQL</title>
		<link>http://classyllama.com/development/magento-development/turn-on-templateblock-hints-using-mysql/</link>
		<comments>http://classyllama.com/development/magento-development/turn-on-templateblock-hints-using-mysql/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 14:48:09 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=221</guid>
		<description><![CDATA[When doing frontend development with Magento, there are many times when I want to turn on template/block hints for just one page load.  I don&#8217;t like having to wait on the Magento admin to load up the System > Configuration > Developer page, switch to Website view, and then turn on template/path hints.  [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/turn-on-templateblock-hints-using-mysql/" title="Enable/disable template/block Hints Using MySQL"><img src="http://classyllama.com/wp-content/uploads/2010/01/Screen-shot-2010-01-21-at-8.44.06-AM.png" alt="" class="feed-image" /></a><p>When doing frontend development with Magento, there are many times when I want to turn on template/block hints for just one page load.  I don&#8217;t like having to wait on the Magento admin to load up the System > Configuration > Developer page, switch to Website view, and then turn on template/path hints.  I have written a couple of MySQL snippets that allow me to enable/disable hints with one query.</p>
<p>I wrote the scripts so that for clean Magento installs, they will insert the necessary records into the core_config_data table.  For Magento installs that have had the hints enabled/disabled, the record will already be present in the config table, so the script will just update that record.
</p>
<h3>Enable template/block hints for the first* <em>website</em></h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p221code32'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22132"><td class="code" id="p221code32"><pre class="mysql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- Enable template hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints <span style="color: #CC0099;">=</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'websites'</span><span style="color: #000033;">,</span><span style="color: #008000;">'1'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints'</span><span style="color: #000033;">,</span> @template_hints<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints<span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;">-- Enable block hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints_blocks <span style="color: #CC0099;">=</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'websites'</span><span style="color: #000033;">,</span><span style="color: #008000;">'1'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints<span style="color: #008080; font-weight: bold;">_</span>blocks'</span><span style="color: #000033;">,</span> @template_hints_blocks<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints_blocks<span style="color: #000033;">;</span></pre></td></tr></table></div>

<h3>Disable template/block hints for the first* <em>website</em></h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p221code33'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22133"><td class="code" id="p221code33"><pre class="mysql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- Enable template hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'websites'</span><span style="color: #000033;">,</span><span style="color: #008000;">'1'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints'</span><span style="color: #000033;">,</span> @template_hints<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints<span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;">-- Enable block hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints_blocks <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'websites'</span><span style="color: #000033;">,</span><span style="color: #008000;">'1'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints<span style="color: #008080; font-weight: bold;">_</span>blocks'</span><span style="color: #000033;">,</span> @template_hints_blocks<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints_blocks<span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>As I covered in <a href="http://classyllama.com/magento/development/enable-templateblock-hints-in-admin-panel/">this post</a>, it is possible to turn on hints at a global level, which activates hints for all website and for the admin panel.  This is useful if you&#8217;re making customizations to the admin panel, or if you have multiple websites for which you&#8217;re wanting to activate/deactivate hints at the same time.  The following two snippets modify hints at a global level:</p>
<h3>Enable template/block hints for the <em>admin panel</em> and ALL <em>websites</em></h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p221code34'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22134"><td class="code" id="p221code34"><pre class="mysql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- Enable template hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints <span style="color: #CC0099;">=</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'default'</span><span style="color: #000033;">,</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints'</span><span style="color: #000033;">,</span> @template_hints<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints<span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;">-- Enable block hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints_blocks <span style="color: #CC0099;">=</span> <span style="color: #008080;">1</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'default'</span><span style="color: #000033;">,</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints<span style="color: #008080; font-weight: bold;">_</span>blocks'</span><span style="color: #000033;">,</span> @template_hints_blocks<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints_blocks<span style="color: #000033;">;</span></pre></td></tr></table></div>

<h3>Disable template/block hints for the <em>admin panel</em> and ALL <em>websites</em></h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p221code35'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p22135"><td class="code" id="p221code35"><pre class="mysql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">-- Enable template hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'default'</span><span style="color: #000033;">,</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints'</span><span style="color: #000033;">,</span> @template_hints<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints<span style="color: #000033;">;</span>
<span style="color: #808080; font-style: italic;">-- Enable block hints</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=SET&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">SET</span></a> @template_hints_blocks <span style="color: #CC0099;">=</span> <span style="color: #008080;">0</span><span style="color: #000033;">;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> <span style="color: #008000;">`core<span style="color: #008080; font-weight: bold;">_</span>config<span style="color: #008080; font-weight: bold;">_</span>data`</span> <span style="color: #FF00FF;">&#40;</span> <span style="color: #008000;">`scope`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`scope<span style="color: #008080; font-weight: bold;">_</span>id`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`path`</span><span style="color: #000033;">,</span> <span style="color: #008000;">`value`</span><span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'default'</span><span style="color: #000033;">,</span><span style="color: #008000;">'0'</span><span style="color: #000033;">,</span><span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints<span style="color: #008080; font-weight: bold;">_</span>blocks'</span><span style="color: #000033;">,</span> @template_hints_blocks<span style="color: #FF00FF;">&#41;</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=ON&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">ON</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=DUPLICATE%20KEY&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">DUPLICATE KEY</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=UPDATE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">UPDATE</span></a> <span style="color: #008000;">`value`</span><span style="color: #CC0099;">=</span>@template_hints_blocks<span style="color: #000033;">;</span></pre></td></tr></table></div>

<p>* If you have multiple websites, you&#8217;ll need to update the &#8216;1&#8242; value set for the website field to reflect the ID of your website.  If you have multiple websites, you can just turn on hints globally using the last two SQL snippets.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/turn-on-templateblock-hints-using-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Initial Magento Setup Development Tips</title>
		<link>http://classyllama.com/development/magento-development/magento-initial-setup/</link>
		<comments>http://classyllama.com/development/magento-development/magento-initial-setup/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 14:27:18 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=185</guid>
		<description><![CDATA[Over the past year and a half of developing Magento sites, our development team has created a standard set of modifications/tweaks that we make to every Magento installation.
1. Automatically turn on developer mode based on domain.
We have a stage site setup for all of our projects at stage..com.  We also develop projects locally at [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/magento-initial-setup/" title="Initial Magento Setup Development Tips"><img src="http://classyllama.com/wp-content/uploads/2009/12/Screen-shot-2009-12-30-at-8.05.52-AM-718x80.png" alt="" class="feed-image" /></a><p>Over the past year and a half of developing Magento sites, our development team has created a standard set of modifications/tweaks that we make to every Magento installation.</p>
<h2>1. Automatically turn on developer mode based on domain.</h2>
<p>We have a stage site setup for all of our projects at stage.<domain_name>.com.  We also develop projects locally at either .dev or .local (based on developer preference).  This snippet of code will only enable error reporting and Magento&#8217;s developer mode on stage or local domains.</p>
<p>Insert the following code after &#8220;require_once $mageFilename;&#8221; in index.php</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p185code39'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p18539"><td class="code" id="p185code39"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># If the domain is ***.dev, ***.local or stage.**** then run site in developer mode and turn on error reporting
</span><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.dev'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ocal'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
  <span style="color: #339933;">||</span> <a href="http://www.php.net/strstr"><span style="color: #990000;">strstr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_HOST'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'stage.'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	Mage<span style="color: #339933;">::</span><span style="color: #004000;">setIsDeveloperMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<a href="http://www.php.net/ini_set"><span style="color: #990000;">ini_set</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'display_errors'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>2. Enable logging</h2>
<p>Magento has a built-in logging method that allows you to log any variable type to a log file.  This is very helpful when building Magento modules, as you can easily inspect data structures, without having to open a debugging session to inspect the variables in local scope.  By default, logging is turned off in Magento.  To enable logging, go to the &#8220;Developer&#8221; tab on the &#8220;System > Configuration&#8221; page.  Change the &#8220;Enabled&#8221; select list under the &#8220;Log Settings&#8221; section to &#8220;Yes&#8221; and then save the page.</p>
<p>You can log variables to the Magento log using the following code:  Mage::log($variable);  By default, logs are stored in var/log/system.log</p>
<p>Here are some example usages of Mage::log()</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p185code40'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p18540"><td class="code" id="p185code40"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Log data from a Model
</span><span style="color: #000088;">$model</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Log data from a Collection
</span><span style="color: #000088;">$collection</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getResourceModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product_collection'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttributeToSelect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Log data from array
</span><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bar'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'foo'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If you&#8217;re developing on a Mac, I&#8217;d recommend opening the system.log file with the Console app.  If you&#8217;re on a *nix based machine, you &#8220;tail&#8221; the latest contents of the log file using the following bash command:<br />
 tail -f</p>
<p>/var/system.log</p>
<p><br class="spacer_" /></p>
<h2>3. Enhance error backtraces</h2>
<p>All of our developers use <a href="http://www.xdebug.org/index.php">xdebug</a> as a part of their Apache configuration.  Xdebug has two main benefits: (1) It allows us to use PDT to debug PHP applications. (2) It overrides the default PHP error messages with detailed, fully customizable error backtraces.  You can see an example backtrace below:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2009/12/Screen-shot-2009-12-30-at-8.05.52-AM.png"><img class="alignleft size-large wp-image-191" title="Xdebug Error Backtrace" src="http://classyllama.com/wp-content/uploads/2009/12/Screen-shot-2009-12-30-at-8.05.52-AM-718x398.png" alt="Xdebug Error Backtrace" width="718" height="398" /></a></p>
<p>This is what that error would look like without xdebug:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2009/12/Screen-shot-2009-12-30-at-8.10.01-AM.png"><img class="alignleft size-large wp-image-193" title="Generic Magento Error" src="http://classyllama.com/wp-content/uploads/2009/12/Screen-shot-2009-12-30-at-8.10.01-AM-718x101.png" alt="Generic Magento Error" width="718" height="101" /></a></p>
<p>Magento has built-in error and exception handling.  Since errors are being handled by Magento, we have to modify a core file to make Magento let PHP/xdebug handle the displaying of the messages.</p>
<p>In a future blog post, will cover how to make Magento let xdebug handle exceptions</p>
<p>In app/code/core/Mage/Core/Model/App.php, replace the setErrorHandler() method with the setErrorHandler() method below:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p185code41'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p18541"><td class="code" id="p185code41"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setErrorHandler<span style="color: #009900;">&#40;</span><span style="color: #000088;">$handler</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// HACK: Magento should only handle errors if developer mode is off</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">getIsDeveloperMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        	<a href="http://www.php.net/set_error_handler"><span style="color: #990000;">set_error_handler</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handler</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// END HACK</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Modifying core Magento files is never recommended, but if Magento gets upgraded and this change gets overridden, there won&#8217;t be an issue, since it&#8217;s not critical for the site to function.</p>
<h2>4. Enhance exception backtraces</h2>
<p>In this <a href="http://classyllama.com/development/magento-development/enabling-xdebugs-exception-handler-in-magento/">Enabling Xdebug’s Exception Handler in Magento</a> blog post you can read about how to modify Magento to let Xdebug handle exceptions.</p>
<h2>Summary</h2>
<p>Hopefully these few tips will help you in your Magento development.  If you have any general tips for Magento development, I&#8217;d love to hear about them.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/magento-initial-setup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Shortening Increment ID length for Orders, Invoices, and Shipments</title>
		<link>http://classyllama.com/development/magento-development/shortening-increment-id-length-for-orders-invoices-and-shipments/</link>
		<comments>http://classyllama.com/development/magento-development/shortening-increment-id-length-for-orders-invoices-and-shipments/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 02:01:20 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=171</guid>
		<description><![CDATA[We recently had a client who needed to shorten the default Magento Increment ID length from the default 9 characters (eg 100000000) to 6 characters.  This can be accomplished by modifying the &#8220;increment_pad_length&#8221; in the &#8220;eav_entity_type&#8221; for whatever entity you&#8217;re wanting to modify.  Here is a screenshot of the resulting table:


If you&#8217;re wanting to change [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/shortening-increment-id-length-for-orders-invoices-and-shipments/" title="Shortening Increment ID length for Orders, Invoices, and Shipments"><img src="http://classyllama.com/wp-content/uploads/2009/10/magento_shorten_increment_id-718x80.jpg" alt="" class="feed-image" /></a><p>We recently had a client who needed to shorten the default Magento Increment ID length from the default 9 characters (eg 100000000) to 6 characters.  This can be accomplished by modifying the &#8220;increment_pad_length&#8221; in the &#8220;eav_entity_type&#8221; for whatever entity you&#8217;re wanting to modify.  Here is a screenshot of the resulting table:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2009/10/magento_shorten_increment_id.jpg"><img class="alignleft size-large wp-image-173" title="magento_shorten_increment_id" src="http://classyllama.com/wp-content/uploads/2009/10/magento_shorten_increment_id-718x337.jpg" alt="magento_shorten_increment_id" width="718" height="337" /></a></p>
<p><br class="spacer_" /></p>
<p>If you&#8217;re wanting to change the number from which Magento starts counting orders/invoices/shipments, or wanting to change the prefix for those entities, check out this great post by Timothy at Elias: http://eliasinteractive.com/blog/magento-ecommerce-how-to-reset-all-test-order-information-and-set-unique-prefix-for-orders-invoices-shipments-and-credit-memos/</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/shortening-increment-id-length-for-orders-invoices-and-shipments/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Custom Admin Theme</title>
		<link>http://classyllama.com/development/magento-development/custom-adminhtml-theme/</link>
		<comments>http://classyllama.com/development/magento-development/custom-adminhtml-theme/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 18:16:40 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://stage.classyllama.com/?p=21</guid>
		<description><![CDATA[Our Objective
If you need to make adjustments to the adminhtml theme files (template, layout, or skin), you have two options for accomplishing this.
Here&#8217;s an example of what we would want to accomplish:
Files in
/app/design/adminhtml/default/custom_admin_theme/
need to override files in:
/app/design/adminhtml/default/default/
Likewise, files in
/skin/adminhtml/default/custom_admin_theme/
need to override files in:
/skin/adminhtml/default/default/
The following two options accomplish this functionality:
Option 1 &#8211; &#8220;Admin Theme&#8221; module
Ivan Weiler [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/custom-adminhtml-theme/" title="Custom Admin Theme"><img src="http://classyllama.com/wp-content/uploads/2009/07/cls_admin_header.jpg" alt="" class="feed-image" /></a><h2>Our Objective</h2>
<p>If you need to make adjustments to the adminhtml theme files (template, layout, or skin), you have two options for accomplishing this.</p>
<p>Here&#8217;s an example of what we would want to accomplish:<br />
Files in<br />
/app/design/adminhtml/default/custom_admin_theme/<br />
need to override files in:<br />
/app/design/adminhtml/default/default/</p>
<p>Likewise, files in<br />
/skin/adminhtml/default/custom_admin_theme/<br />
need to override files in:<br />
/skin/adminhtml/default/default/</p>
<p>The following two options accomplish this functionality:</p>
<h2>Option 1 &#8211; &#8220;Admin Theme&#8221; module</h2>
<p>Ivan Weiler from Inchoo has created a module that allows you to specify your own custom theme using the same config page you use to specify custom frontend themes.  You can download this module <a href="http://www.magentocommerce.com/extension/reviews/module/1086/admin-theme">here</a> (note: this module is currently in Alpha, so you&#8217;ll need to modify the setting of your downloader before being able to download it). Here is a screenshot of this module in action:</p>
<a class="lightbox" href="http://stage.classyllama.com/wp-content/uploads/2009/07/custom_admin_theme.png"><img class="size-full wp-image-23" title="&quot;Admin Theme&quot; Screenshot" src="http://stage.classyllama.com/wp-content/uploads/2009/07/custom_admin_theme.png" alt="&quot;Admin Theme&quot; Screenshot"  /></a>
<h2>Option 2 &#8211; Add XML to your module&#8217;s config file</h2>
<p>If you don&#8217;t want to install a module just to enable this functionality, you can add the following XML code inside the <config></config> tag inside the config.xml file of any of your active modules.  Alternatively, you can add this XML to your /app/etc/local.xml file.  I prefer this option, due to its simplicity and the fact that the store administrator will have no need to update the adminhtml theme from the admin panel.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p21code44'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2144"><td class="code" id="p21code44"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
...
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stores<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;admin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #808080; font-style: italic;">&lt;!-- custom admin theme --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;design<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;theme<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>custom_admin_theme<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/theme<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/design<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/admin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stores<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>	
...
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The code above overrides the XML from the /app/code/core/Mage/Adminhtml/etc/config.xml lines 410-422</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p21code45'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2145"><td class="line_numbers"><pre>410
411
412
413
414
415
416
417
418
419
420
421
422
</pre></td><td class="code" id="p21code45"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;stores<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;admin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #808080; font-style: italic;">&lt;!-- default admin design package and theme --&gt;</span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;design<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>default<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;theme<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>default<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/default<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/theme<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/design<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/admin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/stores<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/custom-adminhtml-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable Template/Block Hints in Admin Panel</title>
		<link>http://classyllama.com/development/magento-development/enable-templateblock-hints-in-admin-panel/</link>
		<comments>http://classyllama.com/development/magento-development/enable-templateblock-hints-in-admin-panel/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 14:22:43 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://stage.classyllama.com/?p=3</guid>
		<description><![CDATA[Anyone that has developed a theme in Magento knows how helpful template/block hints are.  They help quickly identify which files are being loaded for a specific page.
Magento&#8217;s admin panel uses the exact same design pattern as the frontend (layouts + blocks + templates).  If you&#8217;ve ever done any modifications to the Magento admin [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/enable-templateblock-hints-in-admin-panel/" title="Enable Template/Block Hints in Admin Panel"><img src="http://classyllama.com/wp-content/uploads/2009/07/magento_hints_turned_on-718x80.png" alt="Magento Admin - Hints Turned On" class="feed-image" /></a><p>Anyone that has developed a theme in Magento knows how helpful template/block hints are.  They help quickly identify which files are being loaded for a specific page.</p>
<p>Magento&#8217;s admin panel uses the exact same design pattern as the frontend (layouts + blocks + templates).  If you&#8217;ve ever done any modifications to the Magento admin panel, you&#8217;ve probably tried to turn on template/block hints for the admin panel.  The only problem is, Magento doesn&#8217;t have built-in support for this.  I did some digging around and found out how to enable this feature in the admin panel.</p>
<h2>Step 1 &#8211; Connect to database</h2>
<p>Using your favorite database administration tool, connect to your Magento database.  These are tools I&#8217;ve used and recommend:  <a href="http://www.navicat.com/en/products/navicat_mysql/mysql_overview.html" target="_blank">Navicat</a> ($129),  <a href="http://dev.mysql.com/downloads/gui-tools/5.0.html" target="_blank">MySQL Query Browser</a> (Free), <a href="http://www.sequelpro.com/" target="_blank">Sequel Pro</a> (Mac Only &#8211; Free), or <a href="http://www.phpmyadmin.net/home_page/index.php" target="_blank">phpMyAdmin</a> (free).</p>
<h2>Step 2 &#8211; Enter values into &#8216;core_config_data&#8217; table</h2>
<p>Run the following query on the Magento database:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code48'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p348"><td class="code" id="p3code48"><pre class="mysql" style="font-family:monospace;"><a href="http://search.mysql.com/search?site=refman-51&amp;q=INSERT&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INSERT</span></a> <a href="http://search.mysql.com/search?site=refman-51&amp;q=INTO&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">INTO</span></a> core_config_data <span style="color: #FF00FF;">&#40;</span>scope<span style="color: #000033;">,</span> scope_id<span style="color: #000033;">,</span> path<span style="color: #000033;">,</span> <a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUE&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">value</span></a><span style="color: #FF00FF;">&#41;</span>
<a href="http://search.mysql.com/search?site=refman-51&amp;q=VALUES&amp;lr=lang_en"><span style="color: #990099; font-weight: bold;">VALUES</span></a> <span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'default'</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints'</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">,</span>
<span style="color: #FF00FF;">&#40;</span><span style="color: #008000;">'default'</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008000;">'dev/debug/template<span style="color: #008080; font-weight: bold;">_</span>hints<span style="color: #008080; font-weight: bold;">_</span>blocks'</span><span style="color: #000033;">,</span> <span style="color: #008080;">1</span><span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></td></tr></table></div>

<h2>Step 3 &#8211; Test in admin panel</h2>
<p>Once you make this addition to the core_config_data database, template/block hints should show up in the admin panel.  Here is a screenshot of the CMS Page with hints turned on:</p>
<div id="attachment_10" class="wp-caption alignnone" style="width: 957px"><a class="lightbox" href="http://stage.classyllama.com/wp-content/uploads/2009/07/magento_hints_turned_on.png"><img class="size-full wp-image-10" title="Magento Admin - Hints Turned On" src="http://stage.classyllama.com/wp-content/uploads/2009/07/magento_hints_turned_on.png" alt="Magento Admin - Hints Turned On" width="947" height="592" /></a><p class="wp-caption-text">Magento Admin - Hints Turned On</p></div>
<h2>Disabling Hints</h2>
<p>When you&#8217;ve finished development want to turn off template hints in the admin panel, open the core_config_data table and change the &#8216;value&#8217; column of the two row you inserted to &#8220;0&#8243;.</p>
<h2>Why does this work?</h2>
<p>For those of you who are like me and want to know the &#8220;why&#8221; as well as the &#8220;how&#8221;, I&#8217;m going to go over why this works.  Here is the Magento code that checks to see if template/blocks hints are enabled:</p>
<h5>File: /app/code/core/Mage/Core/Block/Template.php (Magento 1.3.2)</h5>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p3code49'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p349"><td class="line_numbers"><pre>109
110
111
112
113
114
115
116
117
118
</pre></td><td class="code" id="p3code49"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getShowTemplateHints<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_null"><span style="color: #990000;">is_null</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_showTemplateHints</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_showTemplateHints</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getStoreConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dev/debug/template_hints'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">&amp;&amp;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isDevAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_showTemplateHintsBlocks</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getStoreConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dev/debug/template_hints_blocks'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">&amp;&amp;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isDevAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$_showTemplateHints</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The &#8220;Mage::getStoreConfig&#8221; method checks for config values that are set in the current scope (ie, default, website, store, store view).  In the admin panel, only values set in the &#8220;Default Scope&#8221; are loaded.</p>
<p>Magento only allows you to turn on hints when you&#8217;re in the configuration scope of a Website or Store View.  This means that when the code above tries to load the configuration, it returns &#8220;null&#8221; because that config value isn&#8217;t set in the &#8220;Default Config&#8221; scope.  Running the MySQL query above adds the hint config values to the &#8220;Default Config&#8221; scope.  Here is a screenshot showing the settings for turning on the hints &#8211; notice that the &#8220;Main Website&#8221; configuration scope is selected.</p>
<div id="attachment_11" class="wp-caption alignnone" style="width: 936px"><a href="http://stage.classyllama.com/wp-content/uploads/2009/07/magento_config_scope_selection.png" class="lightbox"><img class="size-full wp-image-11" title="Magento Config Scope Selection" src="http://stage.classyllama.com/wp-content/uploads/2009/07/magento_config_scope_selection.png" alt="Magento Config Scope Selection" width="926" height="261" /></a><p class="wp-caption-text">Magento Config Scope Selection</p></div>
<h2>Conclusion</h2>
<p>I hope this helps you in your development of Magento modules that integrate with the admin panel.   I considering writing a module to enable the hints to be turned on in the &#8220;Default Scope&#8221;, but decided against it, due to the simplicity of the method outlined in this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/enable-templateblock-hints-in-admin-panel/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
