<?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>Sun, 18 Dec 2011 00:03:54 +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>Magento Modules and the Community</title>
		<link>http://classyllama.com/magento/magento-modules-and-the-community/</link>
		<comments>http://classyllama.com/magento/magento-modules-and-the-community/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 17:05:35 +0000</pubDate>
		<dc:creator>jhodges</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento Development]]></category>
		<category><![CDATA[Management]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Modules]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=1495</guid>
		<description><![CDATA[This post outlines some of our thoughts about the state of the Magento module community, and an idea for how Magento can improve the quality of that community.
Here at Classy Llama Studios we create our own Magento modules every day and have high standards for any module that we write.  These standards include having properly [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/magento/magento-modules-and-the-community/" title="Magento Modules and the Community"><img src="http://classyllama.com/wp-content/uploads/2011/10/MagentoConnect.jpg" alt="" class="feed-image" /></a><p><img class="alignnone size-full wp-image-1499" title="MagentoConnect" src="http://classyllama.com/wp-content/uploads/2011/10/MagentoConnect.jpg" alt="MagentoConnect" width="718" height="80" /></p>
<p>This post outlines some of our thoughts about the state of the Magento module community, and an idea for how Magento can improve the quality of that community.</p>
<p>Here at Classy Llama Studios we create our own Magento modules every day and have high standards for any module that we write.  These standards include having properly commented code, adhering to Zend programming standards, and having both the code and functionality of the module reviewed before it is released.  Magento is great because, instead of having to write every module that we use, there are numerous other quality development companies whose modules we can draw from for sites that we develop.  Unfortunately, there are a lot of modules out there that are not quality.  Issues with modules that we encounter include poorly written code, SQL vulnerabilities, improper code domain separation, and improper utilization of the Magento Application functionalities.  Some of these modules do not even work.</p>
<p>This abundance of modules often leaves us with a challenging question. Do we recommend this module to our client? If we do, we often have to prepare our clients for the possibility of hours of development, in addition to the module cost, that may be required to make the module safe and functional.  The other option is that we have to take a loss to bring the module to the level necessary for use on our customers’ eCommerce platform.  We love our customers and so it is painful for us to have to make either of these choices when the customer is already paying for the module. Because of this, we have been asking ourselves if there is some sort of solution to the problem of poorly coded modules.</p>
<p>The answer we came up with is twofold.  For now, we can buy most of our modules from the great companies who have earned our trust up to this point; these companies include <a href="http://aheadworks.com/">AheadWorks</a>, <a href="http://www.unirgy.com/">Unirgy</a>, and <a href="http://www.webshopapps.com/">WebShopApps</a>. This alleviates the problem but it does not come close to eliminating it.  We know that there are other developers who write quality modules.  We simply don’t know who they are until we have worked with and reviewed their modules.  We think that Magento itself is the solution to this dilemma.</p>
<p>Even though Magento has had explosive growth since the release of Magento 1.0, it has only been three and a half years since its release.  Since then, Magento has gone through dramatic transitions and upgrades turning it into a much more streamlined and powerful system with numerous features and a massive community.  With eBay’s acquisition of Magento, its future looks even brighter.  Since Magento is so young, however, there are certain features and programs that they have not had or taken the time to develop.  We believe that the development of a Magento module certification would be a great step for the company and the community at large.  Magento has over 4800 modules in Magneto Connect, and we realize that reviewing every one of them would be a massive undertaking, so we think that it should be something that Magento would be best able to facilitate on a voluntary basis.  When Magento certifies a module, that module would receive special recognition and be more accessible to developers and store owners. This would take the burden of code review and repair off individual development companies or users purchasing the modules and put it back on the original developers of the module.  While this could take time to implement, we think that it is an endeavor from which the entire Magento community would benefit.</p>
<p>We’ve communicated this idea to Magento.  Here is a snippet of what we’ve told them: … <em>There are many poor quality developers and modules, and the current system doesn’t provide a system of being able to determine which modules are good, and which are not.  The current Magento Connect is much like the Android Marketplace &#8211; thousands of apps, with only a portion of them being high quality.  While we would not like to see the same level of curation as the iOS Marketplace, we would like to see more attention being paid to ensuring that quality modules are promoted, and poor-quality modules are being demoted</em>…</p>
<p>We sincerely hope that Magento does this, but regardless of what they do, we love the platform and will continue to support the company and the community to the best of our ability.  We believe that Magento truly is the eCommerce “Platform for Growth” and that it’s many features, programs, modules, developers, store owners, and fans make it a wonderful and enjoyable platform to work with every day.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/magento/magento-modules-and-the-community/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Wiz 0.9.5: Admin &amp; Developer Tools, Batch Output</title>
		<link>http://classyllama.com/magento/wiz-0-9-5-admin-developers-tools-batch-added/</link>
		<comments>http://classyllama.com/magento/wiz-0-9-5-admin-developers-tools-batch-added/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 22:19:37 +0000</pubDate>
		<dc:creator>nvahalik</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento Development]]></category>
		<category><![CDATA[Wiz]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=1474</guid>
		<description><![CDATA[The latest batch of Wiz updates includes some useful stuff for developers as well as some administrative features.  Included in this bundle of Wizzy goodness is the ability to output any table output in csv, pipe, or tab delimited output.  This makes it very easy to utilize Wiz with other commands (or potentially [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/magento/wiz-0-9-5-admin-developers-tools-batch-added/" title="Wiz 0.9.5: Admin & Developer Tools, Batch Output"><img src="http://classyllama.com/wp-content/uploads/2011/10/wiz-095.png" alt="" class="feed-image" /></a><p>The latest batch of Wiz updates includes some useful stuff for developers as well as some administrative features.  Included in this bundle of Wizzy goodness is the ability to output any table output in csv, pipe, or tab delimited output.  This makes it very easy to utilize Wiz with other commands (or potentially feed information from Wiz back into itself!)</p>
<p>Here is a complete list of the changes in 0.9.5:</p>
<ol>
<li>The internal configuration system was rewritten to look more like Magento&#8217;s own configuration system &#8212; using XML files.  <em>This isn&#8217;t really used heavily yet, but we&#8217;ve got some stuff coming in the next few months that will take full advantage of this.</em></li>
<li>You can now toggle the following &#8220;developer&#8221; flags from the CLI:
<ol>
<li>Allow Symlinks (For templates, 1.5.1.0+)</li>
<li>Logging</li>
<li>JS Merging</li>
<li>CSS Merging</li>
<li>Profiler</li>
</ol>
</li>
<li>You can view all of the above configuration values as well with the <code>devel-config</code> command.</li>
<li>Get a list of all registered event listeners.</li>
<li>Get a list of all Models registered in the system and module rewrites.</li>
<li>Scriptable output.  Output tabular data in csv, pipe-delimieted, or tab-delimited formats.</li>
</ol>
<p>If you just want to get going:<br />
<a href="http://bit.ly/wiz-cli">Browse on Github</a><br />
<a href="http://wizcli.com/">Website / Download</a></p>
<p>Be sure to read over the Readme file on Github for more information about the added commands!</p>
<h2>The Good Stuff</h2>
<p>Okay, so the configuration system isn&#8217;t a <em>huge</em> deal&#8230; but it does open up more potential for 3rd party developers to write plugins that need to store things: usernames, passwords, etc. without having to provide their own storage mechanism.  Let&#8217;s get to the really exciting stuff!</p>
<h3>Developer Configuration</h3>
<p><code></p>
<pre>$ wiz devel-config
+---------------------------------+-------+
| Path                            | Value |
+---------------------------------+-------+
| dev/debug/profiler              | No    |
| dev/js/merge_files              | No    |
| dev/css/merge_css_files         | No    |
| dev/log/active                  | No    |
| dev/debug/template_hints        | No    |
| dev/debug/template_hints_blocks | No    |
| dev/template/allow_symlink      | No    |
+---------------------------------+-------+</pre>
<p></code><br />
You can now flip off/on or view the status of each of these independently.  Each of these work the same way <code>devel-showhints</code> works.</p>
<h3>Developer Helpers</h3>
<p>One of the things I&#8217;m curious about sometimes is to see what modules are listening to what events.  Well, now with a new command, you can see that:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2011/10/wiz-listener-list.png"><img src="http://classyllama.com/wp-content/uploads/2011/10/wiz-listener-list-718x317.png" alt="wiz-listener-list" title="wiz-listener-list" width="718" height="317" class="aligncenter size-large wp-image-1486" /></a></p>
<p><code>wiz devel-listeners</code> give you a list of the events and the modules and their model/method that is responding to that event.</p>
<p>Often times, I want to know what overrides have been performed by other modules.  Now I can see a total picture of what modules provide what models:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2011/10/wiz-model-list.png"><img src="http://classyllama.com/wp-content/uploads/2011/10/wiz-model-list-718x634.png" alt="wiz-model-list" title="wiz-model-list" width="718" height="634" class="aligncenter size-large wp-image-1485" /></a></p>
<p>As you can see, all of the standard models are shown, but you can also see what overrides are performed by all of the modules on the system.</p>
<h3>Scriptable Table Output</h3>
<p>Finally, of the coolest thing (in my opinion) is the scriptable output.  Wiz has a pretty decent table output system that makes it fairly easy for your eyes.  However, getting that data out of the table took me far too much time.  Enter <code>--batch</code>.</p>
<p>The &#8211;batch argument takes the model list we show above and transforms it into:</p>
<p><code>"Model Name","PHP Class"<br />
varien/*,Varien_*<br />
core/*,Mage_Core_Model_*<br />
core_resource/*,Mage_Core_Model_Resource_*<br />
eav/*,Mage_Eav_Model_*<br />
eav_resource/*,Mage_Eav_Model_Resource_*<br />
page/*,Mage_Page_Model_*<br />
install/*,Mage_Install_Model_*<br />
install_resource/*,Mage_Install_Model_Resource_*<br />
admin/*,Mage_Admin_Model_*</code></p>
<p>The &#8211;batch argument can take one of three arguments: csv, pipe, or tab.  csv is the default (as you can see above).  Pipe replaces the commas with &#8220;|&#8221;s and tabs&#8230; well, you get the idea. <img src='http://classyllama.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Now you can take your Wiz output and pipe it through grep, cut, etc. or output straight to CSV and load it up into Excel/Numbers/OpenOffice/etc.</p>
<p>Enjoy!</p>
<h2>Get Wiz</h2>
<p><a href="http://bit.ly/wiz-cli">Browse on Github</a><br />
<a href="http://wizcli.com/">Website / Download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/magento/wiz-0-9-5-admin-developers-tools-batch-added/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Magento Developer Certification</title>
		<link>http://classyllama.com/development/magento-development/we-helped-write-the-new-magent-developer-certification/</link>
		<comments>http://classyllama.com/development/magento-development/we-helped-write-the-new-magent-developer-certification/#comments</comments>
		<pubDate>Mon, 03 Oct 2011 15:34:08 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=1432</guid>
		<description><![CDATA[As many of you know, Magento recently announced their Magento Developer Certification program.  As one of the few partners who have been involved with Magento since it&#8217;s inception, we&#8217;re especially excited to see this long-awaited program finally being launched.
Due to our depth of knowledge and experience with the Magento platform, Magento invited us to be [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/we-helped-write-the-new-magent-developer-certification/" title="The Magento Developer Certification"><img src="http://classyllama.com/wp-content/uploads/2011/10/MagentoDeveloperPlus-718x80.jpg" alt="" class="feed-image" /></a><p><a href="http://classyllama.com/wp-content/uploads/2011/10/MagentoDeveloperPlus.jpg"><img class="alignnone size-large wp-image-1434" title="MagentoDeveloperPlus" src="http://classyllama.com/wp-content/uploads/2011/10/MagentoDeveloperPlus-718x79.jpg" alt="MagentoDeveloperPlus" width="718" height="79" /></a></p>
<p>As many of you know, Magento recently announced their <a href="http://www.magentocommerce.com/services/certification">Magento Developer Certification</a> program.  As one of the few partners who have been involved with Magento since it&#8217;s inception, we&#8217;re especially excited to see this long-awaited program finally being launched.</p>
<p>Due to our depth of knowledge and experience with the Magento platform, Magento invited us to be a part of the Magento Certification <a href="http://www.magentocommerce.com/services/certification-board">Advisory Board.</a> We&#8217;ve been involved in the process of writing questions for the certification for the past couple of months.  I want to extend congratulations to one of our Lead Developer&#8217;s, David Alger, for representing Classy Llama on the Advisory Board.  His contribution to the development of the certification has been substantial &#8211; he even won the award for completing the most number of objectives at a one-week onsite question-writing session.</p>
<p>The certification is going to be beta-launched at the <a href="http://innovate-conference.com/">Innovate</a> conference at the middle of this month and will be announced to the public later this year.  We have four developers who will be at the event and taking the certification.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/we-helped-write-the-new-magent-developer-certification/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Add Custom Layout Handles (e.g. Parent Categories)</title>
		<link>http://classyllama.com/magento/add-custom-layout-handles-e-g-parent-categories/</link>
		<comments>http://classyllama.com/magento/add-custom-layout-handles-e-g-parent-categories/#comments</comments>
		<pubDate>Wed, 01 Jun 2011 21:59:44 +0000</pubDate>
		<dc:creator>kkirchner</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=1212</guid>
		<description><![CDATA[If you ever need custom layout handles in your local.xml,  it&#8217;s fairly simple. In this example the observer method will make a new handle for for categories that have children or not, but you can just modify the method to make whatever handles you desire. (I realized after creating this there&#8217;s already a handle [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/magento/add-custom-layout-handles-e-g-parent-categories/" title="Add Custom Layout Handles (e.g. Parent Categories)"><img src="http://classyllama.com/wp-content/uploads/2011/06/categories.jpg" alt="" class="feed-image" /></a><p>If you ever need custom layout handles in your <a href="http://classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout/">local.xml</a>,  it&#8217;s fairly simple. In this example the observer method will make a new handle for for categories that have children or not, but you can just modify the method to make whatever handles you desire. (I realized after creating this there&#8217;s already a handle for anchored categories with no subcategories, <code>catalog_category_layered_nochildren</code>)</p>
<p>First add this to your config.xml in yourcustommodule:</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('p1212code3'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p12123"><td class="code" id="p1212code3"><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;frontend<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;events<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;controller_action_layout_load_before<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;observers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;yourcustomtheme_observer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>yourcustomtheme/observer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>addHandles<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/method<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/yourcustomtheme_observer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/observers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/controller_action_layout_load_before<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/events<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frontend<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>Then add this method to your observer:</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('p1212code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p12124"><td class="code" id="p1212code4"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> YourPackage_YourCustomTheme_Model_Observer <span style="color: #000000; font-weight: bold;">extends</span> CLS_Core_Model_Abstract
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addHandles<span style="color: #009900;">&#40;</span><span style="color: #000088;">$observer</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">registry</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'current_category'</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: #000088;">$category</span> instanceof Mage_Catalog_Model_Category<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$update</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'core/layout'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUpdate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$fertilility</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getChildrenCategories</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #009900;">&#41;</span> ? <span style="color: #0000ff;">'parent'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'nochildren'</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$update</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addHandle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog_category_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$fertilility</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: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/magento/add-custom-layout-handles-e-g-parent-categories/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>No More Square (White Background) Magento Product Images</title>
		<link>http://classyllama.com/development/magento-development/no-more-square-magento-product-images/</link>
		<comments>http://classyllama.com/development/magento-development/no-more-square-magento-product-images/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 21:01:56 +0000</pubDate>
		<dc:creator>kkirchner</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=1009</guid>
		<description><![CDATA[Do you have a site with product images of varying proportions.  It can be annoying when Magento gives you that white border to make your product image square. Here&#8217;s how customize what color that background is: just add backgroundcolor('000', '000', '000') before the resize() method

&#60;img src="&#60;?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->backgroundcolor('000', '000', '000')->resize(100); ?>" ... [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/no-more-square-magento-product-images/" title="No More Square (White Background) Magento Product Images"><img src="http://classyllama.com/wp-content/uploads/2011/03/keepFrame.jpg" alt="" class="feed-image" /></a><p>Do you have a site with product images of varying proportions.  It can be annoying when Magento gives you that white border to make your product image square. Here&#8217;s how customize what color that background is: just add <code>backgroundcolor('000', '000', '000')</code> before the <code>resize()</code> method</p>
<pre lang="php" colla"+"><code>
&lt;img src="&lt;?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail',<br/> $_image->getFile())->backgroundcolor('000', '000', '000')->resize(100); ?>" ... />
</code>
</pre>
<p>Better yet, get rid of the background using keepFrame(false):</p>
<pre lang="php" colla"+">
&lt;img src="&lt;?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail',<br/> $_image->getFile())->keepFrame(false)->resize(100); ?>" width="100"  ... />
</pre>
<p>Resizing after keepFrame(false) will resize the largest dimension. Don&#8217;t forget to delete your image height and width attributes (if need be)!</p>
<p>Here&#8217;s (most of) the places you&#8217;ll want to change these:</p>
<ul>
<li>catalog/product/view/media.phtml</li>
<li>checkout/cart/item/default.phtml</li>
<li>catalog/product/list.phtml</li>
</ul>
<p>There may be a few more but I bet you can find them. Enjoy your no longer square (white background) images!</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/no-more-square-magento-product-images/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Introducing Wiz, a CLI Tool for Magento</title>
		<link>http://classyllama.com/magento/introducing-wiz-a-cli-tool-magento/</link>
		<comments>http://classyllama.com/magento/introducing-wiz-a-cli-tool-magento/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 04:19:54 +0000</pubDate>
		<dc:creator>nvahalik</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento Development]]></category>
		<category><![CDATA[Management]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=960</guid>
		<description><![CDATA[There is a lot of functionality in Magento that is hard to get to or tedious to work with.  There are so many tasks that developers, designers, and administrators do on a daily basis that require time-consuming trips to the Magento backend.  If you happen to want to do more than one of those operations, [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/magento/introducing-wiz-a-cli-tool-magento/" title="Introducing Wiz, a CLI Tool for Magento"><img src="http://classyllama.com/wp-content/uploads/2011/03/wiz_cli.png" alt="" class="feed-image" /></a><p>There is a lot of functionality in Magento that is hard to get to or tedious to work with.  There are so many tasks that developers, designers, and administrators do on a daily basis that require time-consuming trips to the Magento backend.  If you happen to want to do more than one of those operations, you end up having do each of those tasks one after the other&#8230; if only there was a better way!</p>
<p>It is my pleasure to announce <a href="https://github.com/nvahalik/Wiz">Wiz: a command-line interface tool for working with Magento installations</a>.  It was built to make your work (and subsequently your life) much easier!</p>
<p>Wiz has a whole bunch of great features, but here are some you&#8217;re sure to like:</p>
<ul>
<li>Create an admin user (tested in CE &amp; PE)</li>
<li>Toggle template hints</li>
<li>Enable/disable module names</li>
<li>Enable/disable module output</li>
<li>Run xpath queries over the global config</li>
<li>Enable/disable/clear caches</li>
<li>&#8230; and more!</li>
</ul>
<p>Wiz is a work in progress and hasn&#8217;t been thoroughly tested with every Magento version out there.  However, we&#8217;ve been using it with Professional and Community Edition installations without any major problems.</p>
<p>Things planned for future releases:</p>
<ul>
<li>Templates for building modules</li>
<li>Better support for stores and configuration scopes</li>
<li>More useful utilities like reindexing, cron runs, etc.</li>
</ul>
<p>Your feedback and <a href="https://github.com/nvahalik/Wiz/issues">bug reports</a> are welcome!</p>
<p><strong>Update: Some screenshots for the curious&#8230;</strong></p>
<div id="attachment_970" class="wp-caption alignnone" style="width: 595px"><img class="size-full wp-image-970" title="Wiz: module-list" src="http://classyllama.com/wp-content/uploads/2011/03/wiz_modulelist.png" alt="Wiz: module-list" width="585" height="366" /><p class="wp-caption-text">List all modules, versions, and their statuses without going through the backend.</p></div>
<div id="attachment_968" class="wp-caption alignnone" style="width: 595px"><img class="size-full wp-image-968" title="Wiz: admin-createadmin" src="http://classyllama.com/wp-content/uploads/2011/03/wiz_createadmin.png" alt="Wiz: admin-createadmin" width="585" height="366" /><p class="wp-caption-text">Create an admin user without having to touch the database.</p></div>
<div id="attachment_967" class="wp-caption alignnone" style="width: 596px"><img class="size-full wp-image-967" title="Wiz: cache-*" src="http://classyllama.com/wp-content/uploads/2011/03/cache-status-1.png" alt="Wiz: cache-*" width="586" height="464" /><p class="wp-caption-text">Effortlessly clear, enable, &amp; disable Magento caches.</p></div>
<div id="attachment_966" class="wp-caption alignnone" style="width: 596px"><img class="size-full wp-image-966 " title="Wiz: devel-showhints" src="http://classyllama.com/wp-content/uploads/2011/03/showhints.png" alt="Wiz: devel-showhints" width="586" height="366" /><p class="wp-caption-text">Enable and disable template hints.  Great for theme/skin development.</p></div>
<div id="attachment_965" class="wp-caption alignnone" style="width: 596px"><img class="size-full wp-image-965" title="Wiz: help &amp; sql-cli" src="http://classyllama.com/wp-content/uploads/2011/03/help-sql.png" alt="Wiz: help &amp; sql-cli" width="586" height="464" /><p class="wp-caption-text">Dropping easily into MySQL shell for a Magento install.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/magento/introducing-wiz-a-cli-tool-magento/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Magento Imagine 2011 &#8211; &#8220;Best Practices for Debugging Magento&#8221; assets</title>
		<link>http://classyllama.com/development/magento-development/magento-imagine-2011-best-practices-for-debugging-assets/</link>
		<comments>http://classyllama.com/development/magento-development/magento-imagine-2011-best-practices-for-debugging-assets/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 21:55:27 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=937</guid>
		<description><![CDATA[I just finished giving a presentation at Magento Imagine conference.  I&#8217;m posting the link to the Powerpoint and the video I embedded in my presentation:

Powerpoint presentation: http://bit.ly/fqwvlD
Eclipse/PDT Debugging walkthrough video: http://bit.ly/fEQ0Ma

http://bit.ly/fqwvlD
Cheers!
]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/magento-imagine-2011-best-practices-for-debugging-assets/" title="Magento Imagine 2011 - "Best Practices for Debugging Magento" assets"><img src="http://classyllama.com/wp-content/uploads/2011/02/Screen-shot-2011-02-08-at-1.52.34-PM-718x80.png" alt="" class="feed-image" /></a><p>I just finished giving a presentation at Magento Imagine conference.  I&#8217;m posting the link to the Powerpoint and the video I embedded in my presentation:</p>
<ul>
<li>Powerpoint presentation: <a href="http://bit.ly/fqwvlD">http://bit.ly/fqwvlD</a></li>
<li>Eclipse/PDT Debugging walkthrough video: <a href="http://bit.ly/fEQ0Ma">http://bit.ly/fEQ0Ma</a></li>
</ul>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">http://bit.ly/fqwvlD</div>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/magento-imagine-2011-best-practices-for-debugging-assets/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Get Configurable Super Attributes</title>
		<link>http://classyllama.com/development/magento-development/get-configurable-super-attributes/</link>
		<comments>http://classyllama.com/development/magento-development/get-configurable-super-attributes/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 15:50:24 +0000</pubDate>
		<dc:creator>kkirchner</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=896</guid>
		<description><![CDATA[I wanted to do a check on a configurable product to see if it had a specific attribute.  But not just any attribute, a global attribute used to create associated products within the configurable product &#8211; a &#8220;Super Product Attribute&#8221;.
So here ya go:

    $_product = $this->getProduct();
    $_attributes = [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/get-configurable-super-attributes/" title="Get Configurable Super Attributes"><img src="http://classyllama.com/wp-content/uploads/2010/11/view-718x80.jpg" alt="" class="feed-image" /></a><p>I wanted to do a check on a configurable product to see if it had a specific attribute.  But not just any attribute, a global attribute used to create associated products within the configurable product &#8211; a &#8220;Super Product Attribute&#8221;.</p>
<p>So here ya go:</p>
<pre lang="php" colla"+">
    $_product = $this->getProduct();
    $_attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product);
    foreach($_attributes as $_attribute){
        var_dump($_attribute->debug());
    }
</pre>
<h3>A little bonus: </h3>
<p>The &#8220;->debug()&#8221; method returns the set of values you can use the get magic method on. For example:</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('p896code6'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p8966"><td class="code" id="p896code6"><pre class="html" style="font-family:monospace;">array
  'product_super_attribute_id' =&gt; string '263' (length=3)
  'product_id' =&gt; string '27' (length=2)
  'attribute_id' =&gt; string '80' (length=2)
  'position' =&gt; string '0' (length=1)
  'product_attribute (Mage_Catalog_Model_Resource_Eav_Attribute)' =&gt; 
    array
      'attribute_id' =&gt; string '80' (length=2)
      'entity_type_id' =&gt; string '4' (length=1)
      'attribute_code' =&gt; string 'color' (length=5)
...</pre></td></tr></table></div>

<p>So <em>var_dump($_attribute->getAttributeId());</em> will return <em>string &#8216;80&#8242; (length=2)</em>. Just use &#8220;get&#8221; with the Capitalized Label, getProductAttribute(), getProductId(), getPosition(), etc. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/get-configurable-super-attributes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Magento Developer&#8217;s Paradise Summary</title>
		<link>http://classyllama.com/development/magento-development/magento-developers-paradise-summary/</link>
		<comments>http://classyllama.com/development/magento-development/magento-developers-paradise-summary/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 07:55:58 +0000</pubDate>
		<dc:creator>ehansen</dc:creator>
				<category><![CDATA[Magento Development]]></category>

		<guid isPermaLink="false">http://classyllama.com/?p=875</guid>
		<description><![CDATA[I just arrived back in the US after a long weekend at the Magento Developer&#8217;s Paradise. We (David Alger and myself) had a great time at the event (see photos of event below). There were a number of different types of attendees: Magento Professional &#38; Enterprise development companies, extension development companies (like Webshopapps.com and Sweet [...]]]></description>
			<content:encoded><![CDATA[<a href="http://classyllama.com/development/magento-development/magento-developers-paradise-summary/" title="Magento Developer's Paradise Summary"><img src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3021-718x80.jpg" alt="" class="feed-image" /></a><p>I just arrived back in the US after a long weekend at the Magento Developer&#8217;s Paradise. We (David Alger and myself) had a great time at the event (see photos of event below). There were a number of different types of attendees: Magento Professional &amp; Enterprise development companies, extension development companies (like Webshopapps.com and Sweet Tooth), freelance developers, and Magento team members. We had opportunity to meet with a number of the european partners (Netresearch,Icommerce,Inchoo, et al) and other developers to share ideas on how to successfully build Magento projects.</p>
<p>#magedev was the official hash for all Twitter posts from the conference. View tweets with that hash <a href="http://search.twitter.com/search?q=magedev">here</a>.</p>
<p>Yoav Kutner kicked off the conference with a keynote Sunday morning. Here are some bullet points from his speech:</p>
<ul>
<li>Magento is the faster growing ecommerce platform in the world.
<ul>
<li>&#8220;Magento&#8221; is searched for more often than &#8220;Ecommerce&#8221; on Google</li>
<li>Has been downloaded over 2.5 million times</li>
<li>Over 65K merchants are using Magento
<ul>
<li>This stat has been on the Magento website for a while, but I always wondered how this number was derived: I asked Yoav if Magento pinged any server to notify that it was installed at a certain address and he said that it did not, which is fantastic from a privacy perspective. The only way that Magento Inc. knew the urls of the 65K+ sites is that the admin panel in Magento is setup to check with the Magento servers to see if there are any updates/notifications that should be displayed to the admin user. The list of all urls that have requested updates from the updates RSS feed were culled down to a list of publicly accessible domains and then were tested to ensure that they were an actual Magento site.</li>
</ul>
</li>
<li>It&#8217;s been estimated that over $25 billion has been transacted through the Magento platform.</li>
<li>2.4 million extension downloads</li>
<li>350+ active developers for Magento Connect</li>
<li>180+ solution partners &#8211; 55% of these are in Europe</li>
</ul>
</li>
<li>Magento is being used on continually larger projects &#8211; some Magento sites are nearing the $1B/yr revenue mark.</li>
<li>Magento Community 1.4.2.0 is planned for release in early November. This will be a maintenance release that will resolve 450 issues.</li>
<li>Magento Community 1.5 Roadmap &#8211; CE 1.5 is currently slated to have the following features (subject to change):
<ul>
<li>Order composite products in admin</li>
<li>Edit order without creating a new one</li>
<li>Custom order statuses (this is currently possible by adding an xml node in a config.xml file of a custom module, but 1.5 will allow you to manage order statuses via the admin)</li>
<li>Multistep checkout with no Javascript</li>
<li>Improved import functionality <em>(note: the </em><a href="http://bit.ly/ayWMBp"><em>uRapidflow</em></a><em> extension currently enables these features, plus more) </em>
<ul>
<li>Product types supported:
<ul>
<li>Simple</li>
<li>Virtual</li>
<li>Grouped</li>
<li>Configurable</li>
<li>Gift Card</li>
</ul>
</li>
<li>All types of attributes will be supported</li>
<li>Support for different values per scope</li>
<li>Support for custom options</li>
<li>Support for tiered pricing</li>
</ul>
</li>
</ul>
</li>
<li>Magento Enterprise 1.9.2 is planned for release in mid October (this will also just be a maintenance release) and 1.10 is planned for release at the end of the year. Magento 1.10 planned roadmap:
<ul>
<li>Gift wrapping</li>
<li>CDN/DB as alternative image storage</li>
<li>Support for MSSQL and Oracle databases</li>
</ul>
</li>
<li>There are over 700 Magento Enterprise users</li>
</ul>
<p>Some notes from the other talks at the conference:</p>
<ul>
<li><strong>Magento Connect</strong> &#8211; Jonathan Beri talked about upcoming features in Magento Connect 2.0. Some of the things that are planned for 2.0:
<ul>
<li>The option for Magento developers to sell modules directly within Magento Connect</li>
<li>The ability to sell a module as a subscription, instead of a one-time purchase</li>
<li>More advanced sorting/filtering options</li>
</ul>
</li>
<li><strong>Magento Extensions for the Cloud/Saas</strong> &#8211; Jonathan Beri also talked a little bit about the <a href="http://bit.ly/bv9NNH">OpenSocial</a> extension infrastructure they are planning for the Saas solution they are building. Jonathan previously worked for Myspace where they use OpenSocial for their extension infrastructure.</li>
<li><strong>Performance </strong>- Dima Soroka gave a great presentation on Magento performance optimization. You can review the slides from his presentation here: <a href="http://j.mp/98mlR8">http://j.mp/98mlR8</a></li>
<li><strong>Debugging with PDT+xdebug</strong> &#8211; I gave a quick presentation on the importance of using a robust IDE (PDT, Zend Studio, Netbeans) with debugging capabilities. You can read a blog post I wrote a while back on how to enable rich error and exception backtraces here: <a href="http://bit.ly/co1qc4">http://bit.ly/co1qc4</a>. Yoav mentioned that some members of the Magento development team have recently started using PhpStorm (<a href="http://bit.ly/dbxhkq">http://bit.ly/dbxhkq</a>).</li>
</ul>
<p>Thanks to Thomas, Annemarie, and others at Netresearch.de for the great job you did at hosting the event.  Here are some pictures from the event:</p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-2.46.17-AM.png"><img class="alignnone size-large wp-image-891" title="Screen shot 2010-10-13 at 2.46.17 AM" src="http://classyllama.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-2.46.17-AM-718x594.png" alt="Screen shot 2010-10-13 at 2.46.17 AM" width="718" height="594" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-2.46.27-AM.png"><img class="alignnone size-large wp-image-890" title="Screen shot 2010-10-13 at 2.46.27 AM" src="http://classyllama.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-2.46.27-AM-718x520.png" alt="Screen shot 2010-10-13 at 2.46.27 AM" width="718" height="520" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-2.46.08-AM.png"><img class="alignnone size-large wp-image-892" title="Screen shot 2010-10-13 at 2.46.08 AM" src="http://classyllama.com/wp-content/uploads/2010/10/Screen-shot-2010-10-13-at-2.46.08-AM-718x580.png" alt="Screen shot 2010-10-13 at 2.46.08 AM" width="718" height="580" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_2915.JPG"><img class="alignnone size-large wp-image-880" title="IMG_2915" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_2915-718x538.jpg" alt="IMG_2915" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_2913.JPG"><img class="alignnone size-large wp-image-878" title="IMG_2913" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_2913-718x538.jpg" alt="IMG_2913" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_2914.JPG"><img style="border: 0px initial initial;" title="IMG_2914" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_2914-718x538.jpg" alt="IMG_2914" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3043.JPG"><img style="border: 0px initial initial;" title="IMG_3043" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3043-718x538.jpg" alt="IMG_3043" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3059.JPG"><img class="alignnone size-large wp-image-886" title="IMG_3059" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3059-718x538.jpg" alt="IMG_3059" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3053.JPG"><img class="alignnone size-large wp-image-885" title="IMG_3053" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3053-718x538.jpg" alt="IMG_3053" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3053.JPG"></a><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3032.JPG"><img class="alignnone size-large wp-image-883" title="IMG_3032" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3032-718x538.jpg" alt="IMG_3032" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3021.JPG"><img class="alignnone size-large wp-image-882" title="IMG_3021" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3021-718x538.jpg" alt="IMG_3021" width="718" height="538" /></a></p>
<p><a href="http://classyllama.com/wp-content/uploads/2010/10/IMG_3019.JPG"><img class="alignnone size-large wp-image-881" title="IMG_3019" src="http://classyllama.com/wp-content/uploads/2010/10/IMG_3019-718x538.jpg" alt="IMG_3019" width="718" height="538" /></a></p>
<p>Props to David Alger for many of the above photos.</p>
]]></content:encoded>
			<wfw:commentRss>http://classyllama.com/development/magento-development/magento-developers-paradise-summary/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<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('p791code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p79110"><td class="code" id="p791code10"><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('p791code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p79111"><td class="code" id="p791code11"><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('p791code12'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p79112"><td class="code" id="p791code12"><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>3</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('p558code15'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p55815"><td class="code" id="p558code15"><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('p558code16'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p55816"><td class="code" id="p558code16"><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>4</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('p539code18'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p53918"><td class="code" id="p539code18"><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>6</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('p472code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p47220"><td class="code" id="p472code20"><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('p426code22'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p42622"><td class="code" id="p426code22"><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: #808080; font-style: italic;">&lt;!-- there are a few param you can send to do different things in &lt;urlParams&gt; </span>
<span style="color: #808080; font-style: italic;">                         dig into app/code/core/Mage/Core/Model/Url.php, around line 803 --&gt;</span>                   
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- below adds #add-fragment to the end of your url --&gt;</span>
                <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_fragment&gt;add-fragment&lt;/_fragment&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- below adds ?add-query to the end of your url --&gt;</span>
                <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_query&gt;add-fragment&lt;/_query&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- below gives you a new session id (i think...)--&gt;</span>
                <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_nosid&gt;true&lt;/_nosid&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">&lt;!-- below replaces double quotes, single quotes, greater than, and less than signs </span>
<span style="color: #808080; font-style: italic;">                         to their respective url escaped replacements (%22, %27, %3E, %3C) --&gt;</span>
                <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_escape&gt;i'm-a-blog-url&lt;/_escape&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                <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>30</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('p328code24'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p32824"><td class="code" id="p328code24"><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: #808080; font-style: italic;">&lt;!-- there are a few param you can send to do different things in &lt;urlParams&gt; </span>
<span style="color: #808080; font-style: italic;">                             dig into app/code/core/Mage/Core/Model/Url.php, around line 803 --&gt;</span>                   
&nbsp;
                    <span style="color: #808080; font-style: italic;">&lt;!-- below adds #add-fragment to the end of your url --&gt;</span>
                    <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_fragment&gt;add-fragment&lt;/_fragment&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                    <span style="color: #808080; font-style: italic;">&lt;!-- below adds ?add-query to the end of your url --&gt;</span>
                    <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_query&gt;add-fragment&lt;/_query&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                    <span style="color: #808080; font-style: italic;">&lt;!-- below gives you a new session id (i think...)--&gt;</span>
                    <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_nosid&gt;true&lt;/_nosid&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                    <span style="color: #808080; font-style: italic;">&lt;!-- below replaces double quotes, single quotes, greater than, and less than signs </span>
<span style="color: #808080; font-style: italic;">                             to their respective url escaped replacements (%22, %27, %3E, %3C) --&gt;</span>
                    <span style="color: #808080; font-style: italic;">&lt;!-- &lt;urlParams&gt;&lt;_escape&gt;i'm-a-blog-url&lt;/_escape&gt;&lt;/urlParams&gt; --&gt;</span>
&nbsp;
                    <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>60</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('p353code26'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p35326"><td class="code" id="p353code26"><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>158</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('p315code29'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p31529"><td class="code" id="p315code29"><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('p315code30'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p31530"><td class="code" id="p315code30"><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>2</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('p303code31'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p30331"><td class="code" id="p303code31"><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>1</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('p236code33'); return false;">View Code</a> MYSQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p23633"><td class="code" id="p236code33"><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>16</slash:comments>
		</item>
	</channel>
</rss>

