<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Setting default options for configurable products</title>
	<atom:link href="http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/feed/" rel="self" type="application/rss+xml" />
	<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/</link>
	<description>Taking a run up at the world of Magento</description>
	<lastBuildDate>Fri, 23 Jul 2010 21:20:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Lisa</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-228</link>
		<dc:creator>Lisa</dc:creator>
		<pubDate>Fri, 25 Jun 2010 12:14:31 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-228</guid>
		<description>PS: For simple products - I presume this is for  custom options selection - where do you put the JS code?
Thanks!</description>
		<content:encoded><![CDATA[<p>PS: For simple products &#8211; I presume this is for  custom options selection &#8211; where do you put the JS code?<br />
Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lisa</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-227</link>
		<dc:creator>Lisa</dc:creator>
		<pubDate>Fri, 25 Jun 2010 12:12:01 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-227</guid>
		<description>Hi,

None of these worked for me with IE - especially older versions are giving syntax and unexpected errors.

Also, this does not work if the customer tries to add the product to the cart from the main category screen - instead, he&#039;s redirected to the product page where he&#039;s asked to make a selection (even though the added JS has already done that).
Thanks!</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>None of these worked for me with IE &#8211; especially older versions are giving syntax and unexpected errors.</p>
<p>Also, this does not work if the customer tries to add the product to the cart from the main category screen &#8211; instead, he&#8217;s redirected to the product page where he&#8217;s asked to make a selection (even though the added JS has already done that).<br />
Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AC</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-225</link>
		<dc:creator>AC</dc:creator>
		<pubDate>Tue, 18 May 2010 22:40:32 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-225</guid>
		<description>Jose,  you are god !! thanks a lot!! this was giving me headache</description>
		<content:encoded><![CDATA[<p>Jose,  you are god !! thanks a lot!! this was giving me headache</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-212</link>
		<dc:creator>Jose</dc:creator>
		<pubDate>Thu, 04 Mar 2010 10:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-212</guid>
		<description>For simple products you can do the following:


// set the defaults to the first option
Event.observe(window, &#039;load&#039;, function() {
$$(’.product-options select’).each(function(element) {
element.selectedIndex = 1;
opConfig.reloadPrice();
});
});


Basically, loop through all select items in the product options container and set each one to the first option.

You might also need the line opConfig.reloadPrice() to update the price if the selected option has a price increment.</description>
		<content:encoded><![CDATA[<p>For simple products you can do the following:</p>
<p>// set the defaults to the first option<br />
Event.observe(window, &#8216;load&#8217;, function() {<br />
$$(’.product-options select’).each(function(element) {<br />
element.selectedIndex = 1;<br />
opConfig.reloadPrice();<br />
});<br />
});</p>
<p>Basically, loop through all select items in the product options container and set each one to the first option.</p>
<p>You might also need the line opConfig.reloadPrice() to update the price if the selected option has a price increment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-211</link>
		<dc:creator>Jose</dc:creator>
		<pubDate>Thu, 04 Mar 2010 10:43:40 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-211</guid>
		<description>If you have two, and you want to set the first and also have the second option become active, use the following. The function for firing the onchange event came from http://jehiah.cz/archive/firing-javascript-events-properly


function  fireEvent(element,event){
    if (document.createEventObject){
        // dispatch for IE
        var evt = document.createEventObject();
        return element.fireEvent(&#039;on&#039;+event,evt)
    }   
    else{
        // dispatch for firefox + others
        var evt = document.createEvent(&quot;HTMLEvents&quot;);
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable
        return !element.dispatchEvent(evt);
    }
}

 
Event.observe(window, &#039;load&#039;, function() {
    spConfig.settings[0].selectedIndex = 1;
        obj = spConfig.settings[0]; // this grabs the first select item
         Event.observe(obj,&#039;change&#039;,function(){});
         fireEvent(obj,&#039;change&#039;); // this simulates selecting the first option, which triggers
         spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu

}); 


This code can , of course, be made better. The second part assumes you have two attributes. It may throw an error if you only have one. It can be modified to be more flexible and account for any number of attributes.</description>
		<content:encoded><![CDATA[<p>If you have two, and you want to set the first and also have the second option become active, use the following. The function for firing the onchange event came from <a href="http://jehiah.cz/archive/firing-javascript-events-properly" rel="nofollow">http://jehiah.cz/archive/firing-javascript-events-properly</a></p>
<p>function  fireEvent(element,event){<br />
    if (document.createEventObject){<br />
        // dispatch for IE<br />
        var evt = document.createEventObject();<br />
        return element.fireEvent(&#8216;on&#8217;+event,evt)<br />
    }<br />
    else{<br />
        // dispatch for firefox + others<br />
        var evt = document.createEvent(&#8220;HTMLEvents&#8221;);<br />
        evt.initEvent(event, true, true ); // event type,bubbling,cancelable<br />
        return !element.dispatchEvent(evt);<br />
    }<br />
}</p>
<p>Event.observe(window, &#8216;load&#8217;, function() {<br />
    spConfig.settings[0].selectedIndex = 1;<br />
        obj = spConfig.settings[0]; // this grabs the first select item<br />
         Event.observe(obj,&#8217;change&#8217;,function(){});<br />
         fireEvent(obj,&#8217;change&#8217;); // this simulates selecting the first option, which triggers<br />
         spConfig.settings[1].selectedIndex = 1; // this selects the first option of the second attribute drop menu</p>
<p>}); </p>
<p>This code can , of course, be made better. The second part assumes you have two attributes. It may throw an error if you only have one. It can be modified to be more flexible and account for any number of attributes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jools Wills</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-208</link>
		<dc:creator>Jools Wills</dc:creator>
		<pubDate>Fri, 19 Feb 2010 21:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-208</guid>
		<description>Thanks for the tip! (sorry for late reply!)</description>
		<content:encoded><![CDATA[<p>Thanks for the tip! (sorry for late reply!)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marlon</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-198</link>
		<dc:creator>Marlon</dc:creator>
		<pubDate>Fri, 11 Dec 2009 11:08:08 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-198</guid>
		<description>Hi,

this code runs in IE:


        var spConfig = new Product.Config(getJsonConfig() ?&gt;);
        // set the defaults to the first option - marlon 121109
        Event.observe(window, &#039;load&#039;, function() {
	        spConfig.settings[0].selectedIndex = 1;
	       	spConfig.reloadPrice();
        });        


Regards</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>this code runs in IE:</p>
<p>        var spConfig = new Product.Config(getJsonConfig() ?&gt;);<br />
        // set the defaults to the first option &#8211; marlon 121109<br />
        Event.observe(window, &#8216;load&#8217;, function() {<br />
	        spConfig.settings[0].selectedIndex = 1;<br />
	       	spConfig.reloadPrice();<br />
        });        </p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shylaja</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-197</link>
		<dc:creator>shylaja</dc:creator>
		<pubDate>Tue, 08 Dec 2009 05:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-197</guid>
		<description>In out website also we are using more options,Please tell any one how to select default options in configurable product.Any ideas,very urgent

Thank you</description>
		<content:encoded><![CDATA[<p>In out website also we are using more options,Please tell any one how to select default options in configurable product.Any ideas,very urgent</p>
<p>Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jools Wills</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-114</link>
		<dc:creator>Jools Wills</dc:creator>
		<pubDate>Mon, 10 Aug 2009 21:32:29 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-114</guid>
		<description>Because we only have one option on our store, I never tested with more, sorry. I should try it and see. I did try moving part of the javascript but it didn&#039;t help, but it was late and I was tired so I should maybe try again. I&#039;ll let you know my progress.

Thanks for the feedback.</description>
		<content:encoded><![CDATA[<p>Because we only have one option on our store, I never tested with more, sorry. I should try it and see. I did try moving part of the javascript but it didn&#8217;t help, but it was late and I was tired so I should maybe try again. I&#8217;ll let you know my progress.</p>
<p>Thanks for the feedback.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tegan Snyder</title>
		<link>http://maglife.co.uk/2009/06/24/setting-default-options-for-configurable-products/#comment-113</link>
		<dc:creator>Tegan Snyder</dc:creator>
		<pubDate>Mon, 10 Aug 2009 19:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://maglife.co.uk/?p=87#comment-113</guid>
		<description>It doesn&#039;t seem to work correctly with two or more configurable options in version 1.3.2.1.

It appears to be selecting the first option in the dropdown fine. But if you have a dropdown for Color and one for Size it doesn&#039;t select the size.

I also tried manually setting the selected index. I looked at the source code on the magento pages and at least for me the dropdowns have these ID&#039;s.

 		document.getElementById(&#039;attribute497&#039;).selectedIndex = 1;
		document.getElementById(&#039;attribute496&#039;).selectedIndex = 1;

I think maybe placing this javascript in another location to ensure it doesn&#039;t fire until the DOM layer is fully loaded may help.

Thanks for your time. Have any ideas?</description>
		<content:encoded><![CDATA[<p>It doesn&#8217;t seem to work correctly with two or more configurable options in version 1.3.2.1.</p>
<p>It appears to be selecting the first option in the dropdown fine. But if you have a dropdown for Color and one for Size it doesn&#8217;t select the size.</p>
<p>I also tried manually setting the selected index. I looked at the source code on the magento pages and at least for me the dropdowns have these ID&#8217;s.</p>
<p> 		document.getElementById(&#8216;attribute497&#8242;).selectedIndex = 1;<br />
		document.getElementById(&#8216;attribute496&#8242;).selectedIndex = 1;</p>
<p>I think maybe placing this javascript in another location to ensure it doesn&#8217;t fire until the DOM layer is fully loaded may help.</p>
<p>Thanks for your time. Have any ideas?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
