<?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>Simon Young&#187; Magento Hints &amp; Tips from Simon Young</title>
	<atom:link href="http://simonyoung.net/category/magento/feed/" rel="self" type="application/rss+xml" />
	<link>http://simonyoung.net</link>
	<description>Freelance Front End Web Developer in Manchester &#38; Chester</description>
	<lastBuildDate>Sat, 14 Aug 2010 22:42:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Setting a Default Custom Option in Magento</title>
		<link>http://simonyoung.net/2010/04/20/setting-a-default-custom-option-in-magento/</link>
		<comments>http://simonyoung.net/2010/04/20/setting-a-default-custom-option-in-magento/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 07:52:08 +0000</pubDate>
		<dc:creator>Simon Young</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[magetips]]></category>

		<guid isPermaLink="false">http://simonyoung.net/?p=722</guid>
		<description><![CDATA[Custom Options in Magento are a great way to offer non-stock specific options on products that are being sold - for example allowing the customisation of an item by adding text.  This is very simple to do with the standard functionality.  On the site I am currently building I had a need to offer a custom option on a product - in my specific case it was the nib type on a fountain pen. This article covers how I achieved this with Magento 1.4.]]></description>
			<content:encoded><![CDATA[<p>Custom Options in Magento are a great way to offer non-stock specific options on products that are being sold &#8211; for example allowing the customisation of an item by adding text.  This is very simple to do with the standard functionality.  On the site I am currently building I had a need to offer a custom option on a product &#8211; in my specific case it was the nib type on a fountain pen.  Selecting a different option in this case doesn&#8217;t change the actual product being sold &#8211; it is modified before sale with the required nib which isn&#8217;t held as a stock item.</p>
<p>Of course this is straightforward to add in Magento using a custom option with the type set to &#8216;select&#8217; however I also wanted to set a default custom option for the most commonly ordered option.  As standard Magento provides a &#8216;Please Select&#8217; option at the top of the select box which has the potential to confuse customers.  There is no function in Magento to hide this &#8216;Please Select&#8217; option so it is necessary to override the block which writes out the select box &#8211; and this is how you do it:</p>
<h4>1.  Tell Magento which block you are going to override/rewrite</h4>
<p>To do this, you create a config.xml file for your module as shown below and save this to:</p>
<p> <code>/app/code/local/MageTips/Catalog/etc/config.xml</code></p>
<p>This file tells Magento that we are rewriting the block which is executed when a custom option with the type of &#8216;select&#8217; is configured &#8211; you could easily rewrite another type of custom option using a similar file.</p>
<p><script src="http://gist.github.com/372160.js?file=config.xml"></script></p>
<h4>2.  Activate the custom module</h4>
<p>Once you have create the config file for the module, Magento needs to know that it exists and this is done by creating an XML file as shown below and saving it to:</p>
<p> <code>/app/etc/modules/MageTips_Catalog.xml</code></p>
<p>This file is read by Magento and activates our custom module.</p>
<p><script src="http://gist.github.com/372160.js?file=MageTips_Catalog.xml"></script></p>
<h4>3.  Override the existing Magento block</h4>
<p>With the module activated we now just need to provide the alternative version of the function that should be executed.  In this case it&#8217;s as simple as copying the existing function and commenting out the line that writes out the &#8216;Please Select&#8217; option value.  We extend the existing Magento class at the top of the file (line 27) and then paste in the existing Magento function we are overriding &#8211; getValuesHtml() &#8211; and make the required change at lines 45-48.</p>
<p>This file is saved to:</p>
<p><code>/app/code/local/MageTips/Catalog/Block/Product/View/Options/Type/ Select.php</code></p>
<p>Throughout this example I have used the namespace MageTips for my module but you can use any namespace that makes sense for your project.</p>
<p><script src="http://gist.github.com/372160.js?file=Select.php"></script></p>
<h4>4.  Setup your custom options</h4>
<p>With the changes above in place, you can create custom options for any product and then set their order as normal in the Magento back office.  Whichever option is at the top of the list will be the default custom option for that product.</p>
<p>Hopefully in a future version it will be possible to set a default custom option for a product &#8211; but in the meantime, this option will work just fine.  As always, just remember with future upgrades to check whether the underlying Magento function we are overriding has changed!</p>
]]></content:encoded>
			<wfw:commentRss>http://simonyoung.net/2010/04/20/setting-a-default-custom-option-in-magento/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>A few thoughts on Magento performance</title>
		<link>http://simonyoung.net/2009/07/16/a-few-thoughts-on-magento-performance/</link>
		<comments>http://simonyoung.net/2009/07/16/a-few-thoughts-on-magento-performance/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 00:30:15 +0000</pubDate>
		<dc:creator>Simon Young</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://simonyoung.net/?p=450</guid>
		<description><![CDATA[I still read a huge number of comments on both the Magento forums and via Twitter indicating that people think Magento is slow or a resource hog or performs poorly. In many cases this is a misconception. I think most people familiar with Magento would agree that it is a bit of a beast &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p><span class="drop">I</span> still read a huge number of comments on both the <a href="http://www.magentocommerce.com/boards">Magento forums</a> and via <a href="http://twitter.com">Twitter</a> indicating that people think Magento is slow or a resource hog or performs poorly.  In many cases this is a misconception.  I think most people familiar with Magento would agree that it is a bit of a beast &#8211; it&#8217;s developed for maximum flexibility and extensibility meaning there are a lot of files, lots of templates and in places the HTML &#038; CSS is not entirely ideal.  I think the argument that Magento is over-engineered in places does have some value.</p>
<p>I have found it difficult to get a good performance level out of a simple local installation on OS X 10.5.x &#8211; not helped by a multitude of issues getting PHP setup and running with the required modules for Magento.</p>
<p><strong>However&#8230;</strong> I do have a remote Magento server running with a UK hosting company which is lightning fast with very little modification whatsoever.  The key to it seems to be three-fold:</p>
<h3>1.  Server Specification</h3>
<p>Magento is a pretty processor-intensive and memory-intensive application so having a server that can handle this is a good start.  The specification for my development server is:</p>
<ul>
<li>Dell R200, Dual Core Xeon, 2.33GHz, 4MB Cache</li>
<li>2GB DDR2 RAM</li>
<li>2 x 160GB SATA Hard Drive 7200RPM</li>
<li>Software RAID1</li>
</ul>
<p>On the face of it this seems like a fairly meaty server but it&#8217;s relatively inexpensive &#8211; it costs under £100 per month from <a href="http://www.melbourne.co.uk/">Melbourne Hosting</a> in Manchester who I would highly recommend.</p>
<h3>2.  Server Configuration</h3>
<p>I am by no means a Linux expert and don&#8217;t pretend to be but found that by following some pretty straightforward advice from Varien I was able to significantly improve the database element of the setup.  There is already plenty of detail on this subject &#8211; <a href="http://www.magentocommerce.com/blog/comments/performance-is-key-notes-on-magentos-performance">this article is a good place to start</a> &#8211; particularly the my.cnf modifications.</p>
<p>In addition, the recommendations in that article to install a PHP opcode cache and use a memory-based file system for <code>/var/cache</code> are recommendations you should seriously consider.</p>
<h3>3.  Website Configuration</h3>
<p>Out of the box, the Magento front-end isn&#8217;t particularly quick &#8211; even with the Blank interface as a starting point (you are creating your own interface based on the Blank interface, right?).  The main culprit here is Prototype &#038; Scriptaculous &#8211; they are bulky frameworks and are included uncompressed.  Magento funnels these files through a PHP conduit to compress them in to a single file but in my opinion that still isn&#8217;t ideal &#8211; you are just giving your server more work to do.</p>
<p>Web servers like Apache are brilliant at serving static files &#8211; so let them serve static files.</p>
<p>On most sites I build using Magento, I choose not to use the included javascript framework files but instead to roll my own.  I have found the best way to do this is to create a packed version of the latest Prototype file and then a minified version of the Scriptaculous files and the various Magento specific javascript files.  (For some reason when I packed the Scriptaculous and Magento/Varien-specific files I had some issues).</p>
<p>The result is my typical javascript usage is something like this:</p>
<p><code><br />
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;/skin/frontend/[theme]/default/js/framework.pack.js&quot;&gt;&lt;/script&gt;<br />
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;/skin/frontend/[theme]/default/js/application.min.js&quot;&gt;&lt;/script&gt;<br />
</code></p>
<p>Even though I have two javascript calls rather than one in the standard Magento configuration, the improvements in speed are huge &#8211; largely because Apache is doing what it does best &#8211; serving a packed, gzipped static file.</p>
<p>I will write up point 3 in more detail at some point when I have more time as it&#8217;s quite an involved process to determine which files you need and which you don&#8217;t and of course it varies depending on the site configuration, multi-language requirements etc. however the key points to take away for the amateur performance tweaker are:</p>
<ul>
<li><strong>Don&#8217;t</strong> use an under-specced machine &#8211; it will be painful.</li>
<li><strong>Do</strong> follow Magento&#8217;s basic performance advice &#8211; it makes a big difference.</li>
<li><strong>Do</strong> maximise the efficiency of your front-end javascript and CSS</li>
</ul>
<p>There is no silver bullet for perfect performance &#8211; but the advice above will certainly point you in the right direction.</p>
]]></content:encoded>
			<wfw:commentRss>http://simonyoung.net/2009/07/16/a-few-thoughts-on-magento-performance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Extending an Existing Class in Magento</title>
		<link>http://simonyoung.net/2009/04/29/extending-an-existing-class-in-magento/</link>
		<comments>http://simonyoung.net/2009/04/29/extending-an-existing-class-in-magento/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 22:09:24 +0000</pubDate>
		<dc:creator>Simon Young</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[extending magento]]></category>

		<guid isPermaLink="false">http://simonyoung.net/?p=464</guid>
		<description><![CDATA[One of the key benefits of developing ecommerce sites on the Magento platform is the flexibility of the system. Almost every area of the system can be tweaked and modified to meet exact client requirements. However it&#8217;s also worth noting that Magento is a young platform (only just over a year in production) and new [...]]]></description>
			<content:encoded><![CDATA[<br />
<b>Warning</b>:  file_get_contents(http://gist.github.com/283295.json) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway
 in <b>/home/oneeighty/public_html/simonyoung.net/public/wp-content/plugins/gistson.php</b> on line <b>57</b><br />
<br />
<b>Warning</b>:  file_get_contents(http://gist.github.com/283298.json) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway
 in <b>/home/oneeighty/public_html/simonyoung.net/public/wp-content/plugins/gistson.php</b> on line <b>57</b><br />
<br />
<b>Warning</b>:  file_get_contents(http://gist.github.com/283300.json) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway
 in <b>/home/oneeighty/public_html/simonyoung.net/public/wp-content/plugins/gistson.php</b> on line <b>57</b><br />
<br />
<b>Warning</b>:  file_get_contents(http://gist.github.com/283301.json) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway
 in <b>/home/oneeighty/public_html/simonyoung.net/public/wp-content/plugins/gistson.php</b> on line <b>57</b><br />
<p>One of the key benefits of developing ecommerce sites on the Magento platform is the flexibility of the system.  Almost every area of the system can be tweaked and modified to meet exact client requirements.  However it&#8217;s also worth noting that Magento is a young platform (only just over a year in production) and new versions of the software are released on a regular basis.  With this in mind it&#8217;s important to try and make sites as upgradeable as possible in order to make life easier in the future.  Quite often people see that a change is required and jump straight in to edit the core code &#8211; <strong>bad idea</strong>.  Here I will show you how simple it is to extend an existing class to add new functionality to satisfy a specific requirement.</p>
<p>In the example below I will simply be extending the navigation class to create a slightly modified version of the drawItem class which Magento uses to draw out the main menu.  This modified version will be free of the javascript calls and spans of the original to enable me to provide a cleaner HTML output.</p>
<p>There are 4 basic steps in the process:</p>
<ol>
<li>Create a PHP file for the extended class in the /local code repository</li>
<li>Create an XML file to let Magento know about this extended class</li>
<li>Create a PHP template to utilise the output of the extended class</li>
<li>Modify the XML layout files to bring in this new template</li>
</ol>
<h3>1. Create a PHP file for the extended class in the /local code repository</h3>
<p>In this case I have taken the existing Magento drawItem function and modified it to create a cleaner output and renamed it <strong>drawItemClean</strong>.  This file should be saved to <code>/app/code/local/Magetips/Catalog/Block/Navigation.php</code> &#8211; note you should use whatever name you prefer for your modifications.  I have placed all of my modifications in a namespace called <strong>Magetips</strong> for convenience.</p>

<h3>2. Create an XML file to let Magento know about this extended class</h3>
<p>Once you have extended the base class you need to let Magento know about this when it is loading the framework.  To do this you create an XML configuration file which should be saved to <code>/app/etc/modules/Magetips_Layout.xml</code> &#8211; remember the name will depend on the namespace you have chosen for your code modifications.</p>

<p>This file basically tells Magento you have a local modification for Catalog Navigation and it will find and execute your Navigation.php file from step 1.</p>
<h3>3. Create a PHP template to utilise the output of the extended class</h3>
<p>Once the new function is available we can either modify the existing Magento template to output the results of the new function or add a new custom template for maximum flexibility.  The location of the file will depend on the interface and theme in use &#8211; in our case the location is <code>/design/frontend/blank/default/template/catalog/navigation/custom-home.phtml</code></p>

<p>This code will output our categories into a pre-prepared unordered list and nest subcategories within further child ul tags. You will still need to apply some CSS to match your site design however this code will provide the perfect clean base &#8211; I then customised this further with <a href="http://htmldog.com/articles/suckerfish/dropdowns/">Son of Suckerfish CSS-only dropdown menus</a> which is outside the scope of this initial article.</p>
<h3>4. Modify the XML layout files to bring in this new template</h3>
<p>Finally with all of the code in place we need to add a reference to the appropriate layout XML file to ensure it is shown in the front end of the website.  In our case we want the new clean menu to be shown on all pages where a left hand menu exists and so we add the code below to <code>/design/frontend/blank/default/layout/page.xml</code>.  Again, your file location will vary depending on where you wish to display your new menu but you should add it inside your existing <code><reference></code> block for the area of the page you wish to edit.</p>

<p>These four steps enable you to generate a modified menu function by extending an existing Magento class whilst avoiding modifying your core installation &#8211; therefore keeping your base installation easily upgradeable. The same concepts can be applied to extending any other area of Magento once you have found the correct base class to extend.</p>
<p>If you have any suggestions for changes/improvements to this method please feel free to add these in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://simonyoung.net/2009/04/29/extending-an-existing-class-in-magento/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Showing Subcategories in Magento Static Blocks</title>
		<link>http://simonyoung.net/2009/04/26/showing-subcategories-in-magento-static-blocks/</link>
		<comments>http://simonyoung.net/2009/04/26/showing-subcategories-in-magento-static-blocks/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 17:50:35 +0000</pubDate>
		<dc:creator>Simon Young</dc:creator>
				<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://simonyoung.net/?p=453</guid>
		<description><![CDATA[Whilst the navigation options available in Magento comfortably surpass most other products on the market there are still the occasional problems to deal with.  This article offers a quick ‘How To’ which enables the display of a list of Magento subcategories in a static block on a category page.]]></description>
			<content:encoded><![CDATA[<br />
<b>Warning</b>:  file_get_contents(http://gist.github.com/65226.json) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 502 Bad Gateway
 in <b>/home/oneeighty/public_html/simonyoung.net/public/wp-content/plugins/gistson.php</b> on line <b>57</b><br />
<p><strong>This article was originally published at <a href="http://www.netsprite.co.uk">Netsprite</a> in February 2009.</strong></p>
<p>I’m currently building a new ecommerce stored based on the latest version of Magento.  Whilst the navigation options available surpass most other products on the market there are still the occasional problems to deal with.  I found that in some scenarios I wanted to display subcategories in the main body of a category page rather than them being restricted solely to the navigation bar.</p>
<p>This is particularly useful if you have a main level category with many subcategories and don’t wish to have a random selection of products or a more standard static block to be displayed if a customer lands on the main category.</p>
<p>The code is simple to implement though it’s not guaranteed to work with future versions of Magento &#8211; hence the MIT license designation.  The website I’m working on is still under development so there is no example of this modification however the Gist below includes all of the code required to get up and running.</p>

]]></content:encoded>
			<wfw:commentRss>http://simonyoung.net/2009/04/26/showing-subcategories-in-magento-static-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
