<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sort (show) products by sold quantity in Magento</title>
	<atom:link href="http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/feed" rel="self" type="application/rss+xml" />
	<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento</link>
	<description>Blog site of Branko Ajzele, web application developer.</description>
	<lastBuildDate>Thu, 09 Sep 2010 17:45:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: asmrussel</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-4653</link>
		<dc:creator>asmrussel</dc:creator>
		<pubDate>Wed, 17 Mar 2010 17:51:59 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-4653</guid>
		<description>Nice Work.Thanks.&lt;br&gt;I need further shorting of your code based on Layered Navigation.When i click a category or filterable attribute from the Layered Navigation, it always shows the same product list.How can i further filter of that collection.&lt;br&gt;Thanks Again.&lt;br&gt;A S M Russel</description>
		<content:encoded><![CDATA[<p>Nice Work.Thanks.<br />I need further shorting of your code based on Layered Navigation.When i click a category or filterable attribute from the Layered Navigation, it always shows the same product list.How can i further filter of that collection.<br />Thanks Again.<br />A S M Russel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: asmrussel</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-4652</link>
		<dc:creator>asmrussel</dc:creator>
		<pubDate>Wed, 17 Mar 2010 17:15:05 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-4652</guid>
		<description>Nice Work.Thanks.&lt;br&gt;I need further shorting of your code based on Layered Navigation.When i click a category or filterable attribute from the Layered Navigation, it always shows the same product list.How can i further filter of that collection.&lt;br&gt;Thanks Again.&lt;br&gt;A S M Russel</description>
		<content:encoded><![CDATA[<p>Nice Work.Thanks.<br />I need further shorting of your code based on Layered Navigation.When i click a category or filterable attribute from the Layered Navigation, it always shows the same product list.How can i further filter of that collection.<br />Thanks Again.<br />A S M Russel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-4347</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Thu, 08 Oct 2009 17:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-4347</guid>
		<description>@whoisgregg

I modified the list.phtml code a little to filter based on store and category id&#039;s. I&#039;ve included the modified code block below. It&#039;s a pretty crude hack job but it should give you a good starting point. Hope it helps ;)


// Custom added
$orderFilterType = $this-&gt;getRequest()-&gt;getParam(&#039;order&#039;);
// Part of original template code, just moved to top of the file
$_productCollection=$this-&gt;getLoadedProductCollection();
// Custom added

if(isset($orderFilterType) &amp;&amp; $orderFilterType === &#039;ordered_qty&#039;){
	$storeId = Mage::app()-&gt;getStore()-&gt;getId();
	$categoryId = Mage::registry(&#039;current_category&#039;)-&gt;getId();
	$category = Mage::getModel(&#039;catalog/category&#039;)-&gt;load($categoryId);
	$_productCollection = null;
	$_productCollection = Mage::getResourceModel(&#039;reports/product_collection&#039;)
		-&gt;addAttributeToSelect(&#039;*&#039;)
		-&gt;addOrderedQty()
		-&gt;addCategoryFilter($category)
		-&gt;setStoreId($storeId)
		-&gt;addStoreFilter($storeId)
		-&gt;setOrder(&#039;ordered_qty&#039;,$this-&gt;getRequest()-&gt;getParam(&#039;dir&#039;));

	Mage::getSingleton(&#039;catalog/product_status&#039;)-&gt;addVisibleFilterToCollection($_productCollection);
	Mage::getSingleton(&#039;catalog/product_visibility&#039;)-&gt;addVisibleInCatalogFilterToCollection($_productCollection);
}</description>
		<content:encoded><![CDATA[<p>@whoisgregg</p>
<p>I modified the list.phtml code a little to filter based on store and category id&#8217;s. I&#8217;ve included the modified code block below. It&#8217;s a pretty crude hack job but it should give you a good starting point. Hope it helps <img src='http://activecodeline.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>// Custom added<br />
$orderFilterType = $this-&gt;getRequest()-&gt;getParam(&#8216;order&#8217;);<br />
// Part of original template code, just moved to top of the file<br />
$_productCollection=$this-&gt;getLoadedProductCollection();<br />
// Custom added</p>
<p>if(isset($orderFilterType) &amp;&amp; $orderFilterType === &#8216;ordered_qty&#8217;){<br />
	$storeId = Mage::app()-&gt;getStore()-&gt;getId();<br />
	$categoryId = Mage::registry(&#8216;current_category&#8217;)-&gt;getId();<br />
	$category = Mage::getModel(&#8216;catalog/category&#8217;)-&gt;load($categoryId);<br />
	$_productCollection = null;<br />
	$_productCollection = Mage::getResourceModel(&#8216;reports/product_collection&#8217;)<br />
		-&gt;addAttributeToSelect(&#8216;*&#8217;)<br />
		-&gt;addOrderedQty()<br />
		-&gt;addCategoryFilter($category)<br />
		-&gt;setStoreId($storeId)<br />
		-&gt;addStoreFilter($storeId)<br />
		-&gt;setOrder(&#8216;ordered_qty&#8217;,$this-&gt;getRequest()-&gt;getParam(&#8216;dir&#8217;));</p>
<p>	Mage::getSingleton(&#8216;catalog/product_status&#8217;)-&gt;addVisibleFilterToCollection($_productCollection);<br />
	Mage::getSingleton(&#8216;catalog/product_visibility&#8217;)-&gt;addVisibleInCatalogFilterToCollection($_productCollection);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-5251</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Thu, 08 Oct 2009 17:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-5251</guid>
		<description>@whoisgregg

I modified the list.phtml code a little to filter based on store and category id&#039;s. I&#039;ve included the modified code block below. It&#039;s a pretty crude hack job but it should give you a good starting point. Hope it helps ;)


// Custom added
$orderFilterType = $this-&gt;getRequest()-&gt;getParam(&#039;order&#039;);
// Part of original template code, just moved to top of the file
$_productCollection=$this-&gt;getLoadedProductCollection();
// Custom added

if(isset($orderFilterType) &amp;&amp; $orderFilterType === &#039;ordered_qty&#039;){
	$storeId = Mage::app()-&gt;getStore()-&gt;getId();
	$categoryId = Mage::registry(&#039;current_category&#039;)-&gt;getId();
	$category = Mage::getModel(&#039;catalog/category&#039;)-&gt;load($categoryId);
	$_productCollection = null;
	$_productCollection = Mage::getResourceModel(&#039;reports/product_collection&#039;)
		-&gt;addAttributeToSelect(&#039;*&#039;)
		-&gt;addOrderedQty()
		-&gt;addCategoryFilter($category)
		-&gt;setStoreId($storeId)
		-&gt;addStoreFilter($storeId)
		-&gt;setOrder(&#039;ordered_qty&#039;,$this-&gt;getRequest()-&gt;getParam(&#039;dir&#039;));

	Mage::getSingleton(&#039;catalog/product_status&#039;)-&gt;addVisibleFilterToCollection($_productCollection);
	Mage::getSingleton(&#039;catalog/product_visibility&#039;)-&gt;addVisibleInCatalogFilterToCollection($_productCollection);
}</description>
		<content:encoded><![CDATA[<p>@whoisgregg</p>
<p>I modified the list.phtml code a little to filter based on store and category id&#8217;s. I&#8217;ve included the modified code block below. It&#8217;s a pretty crude hack job but it should give you a good starting point. Hope it helps <img src='http://activecodeline.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>// Custom added<br />
$orderFilterType = $this-&gt;getRequest()-&gt;getParam(&#8216;order&#8217;);<br />
// Part of original template code, just moved to top of the file<br />
$_productCollection=$this-&gt;getLoadedProductCollection();<br />
// Custom added</p>
<p>if(isset($orderFilterType) &amp;&amp; $orderFilterType === &#8216;ordered_qty&#8217;){<br />
	$storeId = Mage::app()-&gt;getStore()-&gt;getId();<br />
	$categoryId = Mage::registry(&#8216;current_category&#8217;)-&gt;getId();<br />
	$category = Mage::getModel(&#8216;catalog/category&#8217;)-&gt;load($categoryId);<br />
	$_productCollection = null;<br />
	$_productCollection = Mage::getResourceModel(&#8216;reports/product_collection&#8217;)<br />
		-&gt;addAttributeToSelect(&#8216;*&#8217;)<br />
		-&gt;addOrderedQty()<br />
		-&gt;addCategoryFilter($category)<br />
		-&gt;setStoreId($storeId)<br />
		-&gt;addStoreFilter($storeId)<br />
		-&gt;setOrder(&#8216;ordered_qty&#8217;,$this-&gt;getRequest()-&gt;getParam(&#8216;dir&#8217;));</p>
<p>	Mage::getSingleton(&#8216;catalog/product_status&#8217;)-&gt;addVisibleFilterToCollection($_productCollection);<br />
	Mage::getSingleton(&#8216;catalog/product_visibility&#8217;)-&gt;addVisibleInCatalogFilterToCollection($_productCollection);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bivek</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-709</link>
		<dc:creator>Bivek</dc:creator>
		<pubDate>Tue, 09 Dec 2008 08:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-709</guid>
		<description>Please see this post and reply:

http://www.magentocommerce.com/boards/viewthread/25393/


Thnk you</description>
		<content:encoded><![CDATA[<p>Please see this post and reply:</p>
<p><a href="http://www.magentocommerce.com/boards/viewthread/25393/" rel="nofollow">http://www.magentocommerce.com/boards/viewthread/25393/</a></p>
<p>Thnk you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bivek</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-5250</link>
		<dc:creator>Bivek</dc:creator>
		<pubDate>Tue, 09 Dec 2008 08:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-5250</guid>
		<description>Please see this post and reply:

http://www.magentocommerce.com/boards/viewthread/25393/


Thnk you</description>
		<content:encoded><![CDATA[<p>Please see this post and reply:</p>
<p><a href="http://www.magentocommerce.com/boards/viewthread/25393/" rel="nofollow">http://www.magentocommerce.com/boards/viewthread/25393/</a></p>
<p>Thnk you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: whoisgregg</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-679</link>
		<dc:creator>whoisgregg</dc:creator>
		<pubDate>Thu, 04 Dec 2008 18:02:20 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-679</guid>
		<description>Great code! Do you happen to know how to get it to only show products from a particular category or store?

When I add in that code, it shows every single product from all the stores running on this particular installation... not ideal. ;)</description>
		<content:encoded><![CDATA[<p>Great code! Do you happen to know how to get it to only show products from a particular category or store?</p>
<p>When I add in that code, it shows every single product from all the stores running on this particular installation&#8230; not ideal. <img src='http://activecodeline.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: whoisgregg</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-5249</link>
		<dc:creator>whoisgregg</dc:creator>
		<pubDate>Thu, 04 Dec 2008 18:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-5249</guid>
		<description>Great code! Do you happen to know how to get it to only show products from a particular category or store?

When I add in that code, it shows every single product from all the stores running on this particular installation... not ideal. ;)</description>
		<content:encoded><![CDATA[<p>Great code! Do you happen to know how to get it to only show products from a particular category or store?</p>
<p>When I add in that code, it shows every single product from all the stores running on this particular installation&#8230; not ideal. <img src='http://activecodeline.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-388</link>
		<dc:creator>david</dc:creator>
		<pubDate>Tue, 11 Nov 2008 22:51:07 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-388</guid>
		<description>Hey thanks for the post. This is exactly what I need...hopefully I can get it to work.

I got the previous &quot;special_price&quot; post working, but for some reason there is no values for $_product-&gt;ordered_qty and &#039;ordered_qty&#039; isn&#039;t in $_product-&gt;debug().  For the special price, as you stated, it is included in this array if there is a special price set.  

Is there something else I need to do to make ordered_qty included it in this array?</description>
		<content:encoded><![CDATA[<p>Hey thanks for the post. This is exactly what I need&#8230;hopefully I can get it to work.</p>
<p>I got the previous &#8220;special_price&#8221; post working, but for some reason there is no values for $_product-&gt;ordered_qty and &#8216;ordered_qty&#8217; isn&#8217;t in $_product-&gt;debug().  For the special price, as you stated, it is included in this array if there is a special price set.  </p>
<p>Is there something else I need to do to make ordered_qty included it in this array?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://activecodeline.com/sort-show-products-by-sold-quantity-in-magento/comment-page-1#comment-5248</link>
		<dc:creator>david</dc:creator>
		<pubDate>Tue, 11 Nov 2008 22:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://activecodeline.com/?p=326#comment-5248</guid>
		<description>Hey thanks for the post. This is exactly what I need...hopefully I can get it to work.

I got the previous &quot;special_price&quot; post working, but for some reason there is no values for $_product-&gt;ordered_qty and &#039;ordered_qty&#039; isn&#039;t in $_product-&gt;debug().  For the special price, as you stated, it is included in this array if there is a special price set.  

Is there something else I need to do to make ordered_qty included it in this array?</description>
		<content:encoded><![CDATA[<p>Hey thanks for the post. This is exactly what I need&#8230;hopefully I can get it to work.</p>
<p>I got the previous &#8220;special_price&#8221; post working, but for some reason there is no values for $_product-&gt;ordered_qty and &#8216;ordered_qty&#8217; isn&#8217;t in $_product-&gt;debug().  For the special price, as you stated, it is included in this array if there is a special price set.  </p>
<p>Is there something else I need to do to make ordered_qty included it in this array?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
