<?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>NemoPS &#187; sales</title>
	<atom:link href="http://nemops.com/tag/sales/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>New Prestashop Module: Countdown Sales</title>
		<link>http://nemops.com/prestashop-module-countdown-sales/</link>
		<comments>http://nemops.com/prestashop-module-countdown-sales/#comments</comments>
		<pubDate>Thu, 06 Feb 2014 10:56:22 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[sales]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1866</guid>
		<description><![CDATA[<p>Showcase the best of your limited offers and catch your customers&#8217; attention by showing sliders and countdowns in your web shop. BUY HERE Video If you periodically add limited offers to your web store, chances are you really need customers to know when they are about to end, to maximize sales. With the Countdown Sales [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-module-countdown-sales/">New Prestashop Module: Countdown Sales</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Showcase the best of your limited offers and catch your customers&#8217; attention by showing sliders and countdowns in your web shop.<br />
<span id="more-1866"></span></p>
<h3><a title="Prestashop Module - Countdown Sales" href="http://store.nemops.com/modules/33-prestashop-countdown-sales.html">BUY HERE</a></h3>
<h3>Video</h3>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/H42W6ku_TO4" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<p>If you periodically add limited offers to your web store, chances are you really need customers to know when they are about to end, to maximize sales. With the Countdown Sales module, this result is only one click ahead after you setup your special prices!</p>
<p>Add them, click on the module&#8217;s configuration page and enable your last special product in the active Flash Sales list. You will be able to display a countdown clock in the key product detail page, right under the add to cart button!</p>
<p>Furthermore, you will be able to choose the exact display of the flash sales lists in both the homepage, column module, and dedicated page (where customers will see the Flash Sales all together at once!).</p>
<h3>Core Features</h3>
<ul>
<li>Multiple product sliders</li>
<li>Javascript Countdowns</li>
<li>Dedicated page with all Flash sales listed</li>
<li>Flexible design</li>
<li>2 navigation types</li>
</ul>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-module-countdown-sales/">New Prestashop Module: Countdown Sales</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-module-countdown-sales/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Christmas sales! 30% off on all Prestashop modules</title>
		<link>http://nemops.com/sales-prestashop-modules/</link>
		<comments>http://nemops.com/sales-prestashop-modules/#comments</comments>
		<pubDate>Tue, 17 Dec 2013 09:23:32 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[sales]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1740</guid>
		<description><![CDATA[<p>Jingle bells, jingle bells. And price drops! All Prestashop modules will be down by 30% till the end of December! Every shop cuts prices during the Christmas period (well not all shops&#8230; but they should!). In any case, I am pleased to announced that from now to the end of the month, all Prestashop Modules [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/sales-prestashop-modules/">Christmas sales! 30% off on all Prestashop modules</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Jingle bells, jingle bells. And price drops! All Prestashop modules will be down by 30% till the end of December!<br />
<span id="more-1740"></span><br />
Every shop cuts prices during the Christmas period (well not all shops&#8230; but they should!). In any case, I am pleased to announced that from now to the end of the month, all Prestashop Modules will have a 30% discount. In addition, all subscribers of the newsletter might get another special discount from Santa Claus soon&#8230; stay tuned!</p>
<h3><a title="Discounted Prestashop Modules" href="http://store.nemops.com">Buy the discounted Prestashop modules here</a></h3>
<p>The post <a rel="nofollow" href="http://nemops.com/sales-prestashop-modules/">Christmas sales! 30% off on all Prestashop modules</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/sales-prestashop-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding a &#8216;sort by sales&#8217; option to Prestashop</title>
		<link>http://nemops.com/sort-by-sales-prestashop/</link>
		<comments>http://nemops.com/sort-by-sales-prestashop/#comments</comments>
		<pubDate>Tue, 12 Nov 2013 11:25:56 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[sales]]></category>
		<category><![CDATA[sort by]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1676</guid>
		<description><![CDATA[<p>Offering the possibility to order products by sales when browsing categories is a great way to have your customers know about your best items. Let&#8217;s see how to add this to Prestashop! Version used: Prestashop 1.5.6 Introduction In order to add the &#8216;sort by sales&#8217; option to the product sort dropdown in Prestashop, a couple [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/sort-by-sales-prestashop/">Adding a &#8216;sort by sales&#8217; option to Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Offering the possibility to order products by sales when browsing categories is a great way to have your customers know about your best items. Let&#8217;s see how to add this to Prestashop!</p>
<p><span id="more-1676"></span></p>
<a class="download-files button style1" href="http://nemops.com/wp-content/uploads/2013/11/sort_by_sales.zip" title="Download Project Files">Download Project Files</a>
<ul>
<li>Version used: <strong>Prestashop 1.5.6</strong></li>
</ul>
<h2>Introduction</h2>
<p>In order to add the &#8216;sort by sales&#8217; option to the product sort dropdown in Prestashop, a couple of files need to be changed. To be specific, we will first edit the template file responsible of displaying the options, <strong>product-sort.tpl</strong>, and then add 2 overrides: <strong>Category.php</strong> (class file, to add the new sort option to the query which grabs products) and <strong>CategoryController.php</strong>, to add the &#8216;sort by sales&#8217; option to the valid list of &#8216;sort by&#8217; values.</p>
<p>It looks longer than it is! Let&#8217;s get started!</p>
<div class="separator"></div>
<h2>Editing the product-sort template file</h2>
<p>First, it is vital that we add the &#8216;sort by sales&#8217; option (for both ascending and descending order, of course!) to our template. Therefore, open up <strong>product-sort.tpl</strong> which you can find in you theme&#8217;s folder. As always, I am using the default theme, so your code might be a little different!</p>
<p>Locate the following code:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
	&lt;option value=&quot;name:asc&quot; {if $orderby eq 'name' AND $orderway eq 'asc'}selected=&quot;selected&quot;{/if}&gt;{l s='Product Name: A to Z'}&lt;/option&gt;
</pre>
<p>Right before it, add:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
	&lt;option value=&quot;sales:desc&quot; {if $orderby eq 'sales' AND $orderway eq 'desc'}selected=&quot;selected&quot;{/if}&gt;{l s='Sales: Best to Worst'}&lt;/option&gt;
	&lt;option value=&quot;sales:asc&quot; {if $orderby eq 'sales' AND $orderway eq 'asc'}selected=&quot;selected&quot;{/if}&gt;{l s='Sales: Worst to Best'}&lt;/option&gt;
</pre>
<p><strong>Note:</strong>you can freely choose where to add those 2 lines, I have chosen the spot above the &#8216;Order by product name&#8217;, but you can really add the new options wherever you want, as long as they sit inside the &lt;select&gt; box.</p>
<p>What we did here was simply adding a visual reference so that customers can choose if they want to order by best sales, with best products first (first option), or worst first (second option).  Of course, these options will not do anything now!</p>
<div class="separator"></div>
<h2>Adding the class override</h2>
<p>Let&#8217;s get dirty now! We need to first add an override for the <strong>Category</strong> class, so that a new parameter (sales) is added to the &#8216;order by&#8217; clause in the sql query which grabs products. If all what I am saying sounds alien to you, be sure you first understand the basics of MySQL (some great articles can be found <a href="http://net.tutsplus.com" title="Web Development Tutorials">here</a>).</p>
<p>Therefore, go to <em>override/classes/</em> and create a new file named <strong>Category.php</strong>. Then, open it up and add the following inside:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

Class Category extends CategoryCore
{

}
?&gt;
</pre>
<p><strong>Note:</strong> you might want to read <a href="http://nemops.com/extending-prestashop-objects/" title="Prestashop Overrides: extending Prestashop Objects">this article about using Prestashop Overrides to extend default functionalities</a> if you never used them!</p>
<p>Then, to save us some trouble, we will copy the original <strong>getProducts()</strong> method of the Category class. It looks like the following, but <strong>be sure you copy your own, if you use a different Prestashop Version than mine! (1.5.6)</strong>:</p>
<pre class="brush: php; title: ; notranslate">

	public function getProducts($id_lang, $p, $n, $order_by = null, $order_way = null, $get_total = false, $active = true, $random = false, $random_number_products = 1, $check_access = true, Context $context = null)
	{
		if (!$context)
			$context = Context::getContext();
		if ($check_access &amp;&amp; !$this-&gt;checkAccess($context-&gt;customer-&gt;id))
			return false;
		
		$front = true;
		if (!in_array($context-&gt;controller-&gt;controller_type, array('front', 'modulefront')))
			$front = false;
			
		if ($p &lt; 1) $p = 1;

		if (empty($order_by))
			$order_by = 'position';
		else
			/* Fix for all modules which are now using lowercase values for 'orderBy' parameter */
			$order_by = strtolower($order_by);

		if (empty($order_way))
			$order_way = 'ASC';
		if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd')
			$order_by_prefix = 'p';
		elseif ($order_by == 'name')
			$order_by_prefix = 'pl';
		elseif ($order_by == 'manufacturer')
		{
			$order_by_prefix = 'm';
			$order_by = 'name';
		}
		elseif ($order_by == 'position')
			$order_by_prefix = 'cp';

		if ($order_by == 'price')
			$order_by = 'orderprice';

		if (!Validate::isBool($active) || !Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way))
			die (Tools::displayError());

		$id_supplier = (int)Tools::getValue('id_supplier');

		/* Return only the number of products */
		if ($get_total)
		{
			$sql = 'SELECT COUNT(cp.`id_product`) AS total
					FROM `'._DB_PREFIX_.'product` p
					'.Shop::addSqlAssociation('product', 'p').'
					LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON p.`id_product` = cp.`id_product`
					WHERE cp.`id_category` = '.(int)$this-&gt;id.
					($front ? ' AND product_shop.`visibility` IN (&quot;both&quot;, &quot;catalog&quot;)' : '').
					($active ? ' AND product_shop.`active` = 1' : '').
					($id_supplier ? 'AND p.id_supplier = '.(int)$id_supplier : '');
			return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)-&gt;getValue($sql);
		}

		$sql = 'SELECT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, product_attribute_shop.minimal_quantity AS product_attribute_minimal_quantity, pl.`description`, pl.`description_short`, pl.`available_now`,
					pl.`available_later`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, MAX(image_shop.`id_image`) id_image,
					il.`legend`, m.`name` AS manufacturer_name, cl.`name` AS category_default,
					DATEDIFF(product_shop.`date_add`, DATE_SUB(NOW(),
					INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).'
						DAY)) &gt; 0 AS new, product_shop.price AS orderprice
				FROM `'._DB_PREFIX_.'category_product` cp
				LEFT JOIN `'._DB_PREFIX_.'product` p
					ON p.`id_product` = cp.`id_product`
				'.Shop::addSqlAssociation('product', 'p').'
				LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
				ON (p.`id_product` = pa.`id_product`)
				'.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').'
				'.Product::sqlStock('p', 'product_attribute_shop', false, $context-&gt;shop).'
				LEFT JOIN `'._DB_PREFIX_.'category_lang` cl
					ON (product_shop.`id_category_default` = cl.`id_category`
					AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').')
				LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
					ON (p.`id_product` = pl.`id_product`
					AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').')
				LEFT JOIN `'._DB_PREFIX_.'image` i
					ON (i.`id_product` = p.`id_product`)'.
				Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
				LEFT JOIN `'._DB_PREFIX_.'image_lang` il
					ON (image_shop.`id_image` = il.`id_image`
					AND il.`id_lang` = '.(int)$id_lang.')
				LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
					ON m.`id_manufacturer` = p.`id_manufacturer`
				WHERE product_shop.`id_shop` = '.(int)$context-&gt;shop-&gt;id.'
					AND cp.`id_category` = '.(int)$this-&gt;id
					.($active ? ' AND product_shop.`active` = 1' : '')
					.($front ? ' AND product_shop.`visibility` IN (&quot;both&quot;, &quot;catalog&quot;)' : '')
					.($id_supplier ? ' AND p.id_supplier = '.(int)$id_supplier : '')
					.' GROUP BY product_shop.id_product';

		if ($random === true)
		{
			$sql .= ' ORDER BY RAND()';
			$sql .= ' LIMIT 0, '.(int)$random_number_products;
		}
		else
			$sql .= ' ORDER BY '.(isset($order_by_prefix) ? $order_by_prefix.'.' : '').'`'.pSQL($order_by).'` '.pSQL($order_way).'
			LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n;

		$result = Db::getInstance(_PS_USE_SQL_SLAVE_)-&gt;executeS($sql);
		if ($order_by == 'orderprice')
			Tools::orderbyPrice($result, $order_way);

		if (!$result)
			return array();

		/* Modify SQL result */
		return Product::getProductsProperties($id_lang, $result);
	}

</pre>
<p>Take this method inside the override Class. Let&#8217;s get to the tricky part!</p>
<p>See that really long string for the <strong>$sql</strong> variable? We need to modify that one. First, locate the following, or in any case the last item of the <strong>SELECT</strong> statement:</p>
<pre class="brush: php; title: ; notranslate">
product_shop.price AS orderprice
</pre>
<p>We need to grab one more value, like this:</p>
<pre class="brush: php; title: ; notranslate">
product_shop.price AS orderprice, ps.quantity AS sales
</pre>
<p><strong>Notice:</strong> we are referring to an alias (ps) which has not been defined yet. Then, for simplicity, we are calling this new parameter &#8216;sales&#8217;. If you remember, we previously used sales:desc and sales:asc for our select box. Well, for simplicity it&#8217;s better to call this new &#8216;order by&#8217; parameter <strong>the same way</strong> across all files, so that we don&#8217;t need to add other parameters to refer to it when it changes!</p>
<p>Now, let&#8217;s join that &#8216;ps&#8217; table we referred to in the select statement, which is product_sale! Locate the last join, which is probably this:</p>
<pre class="brush: php; title: ; notranslate">
LEFT JOIN `'._DB_PREFIX_.'manufacturer` m
					ON m.`id_manufacturer` = p.`id_manufacturer`
</pre>
<p>and after it, <strong>but before the WHERE clause</strong>, add</p>
<pre class="brush: php; title: ; notranslate">
LEFT JOIN '._DB_PREFIX_.'product_sale ps ON ps.id_product = product_shop.id_product
</pre>
<p>And we are done with the class. Again, nothing is working so far, let&#8217;s get to the last step and put everything together with a controller override!</p>
<div class="separator"></div>
<h2>Overriding the CategoryController</h2>
<p>Let&#8217;s create another file, this time inside <em>override/controllers/front</em>. Name it <strong>CategoryController.php</strong> and add the following inside:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php 
Class CategoryController extends CategoryControllerCore
{
?&gt;
</pre>
<p>For this one, we must use a different approach. The native <strong>productSort()</strong> method is nowhere to be found inside CategoryControllerCore. So, why are we extending this? Because that class is extending another as well: <strong>FrontController</strong>. And this last one contains the method we need. If you are used to the rules of <strong>inheritance</strong> in OOP, you know that each class extending another has also access to all the parent&#8217;s methods, and can of course extend those as well. So, CategoryControllerCore, which extends FrontController, has access to its parent&#8217;s <strong>productSort</strong>. Thus (finally!) its own child, our new <strong>CategoryController</strong> know about it&#8217;s grandpa&#8217;s method too!</p>
<p>At this point, if you didn&#8217;t shoot your head, go to <em>classes/controller/</em> and open the original <strong>FrontController.php</strong>. Locate its <strong>productSort()</strong> method:</p>
<pre class="brush: php; title: ; notranslate">
	public function productSort()
	{
		// $this-&gt;orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
		// $this-&gt;orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
		// 'orderbydefault' =&gt; Tools::getProductsOrder('by'),
		// 'orderwayposition' =&gt; Tools::getProductsOrder('way'), // Deprecated: orderwayposition
		// 'orderwaydefault' =&gt; Tools::getProductsOrder('way'),

		$stock_management = Configuration::get('PS_STOCK_MANAGEMENT') ? true : false; // no display quantity order if stock management disabled
		$order_by_values = array(0 =&gt; 'name', 1 =&gt; 'price', 2 =&gt; 'date_add', 3 =&gt; 'date_upd', 4 =&gt; 'position', 5 =&gt; 'manufacturer_name', 6 =&gt; 'quantity', 7 =&gt; 'reference');
		$order_way_values = array(0 =&gt; 'asc', 1 =&gt; 'desc');
		$this-&gt;orderBy = Tools::strtolower(Tools::getValue('orderby', $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')]));
		$this-&gt;orderWay = Tools::strtolower(Tools::getValue('orderway', $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')]));
		if (!in_array($this-&gt;orderBy, $order_by_values))
			$this-&gt;orderBy = $order_by_values[0];
		if (!in_array($this-&gt;orderWay, $order_way_values))
			$this-&gt;orderWay = $order_way_values[0];

		$this-&gt;context-&gt;smarty-&gt;assign(array(
			'orderby' =&gt; $this-&gt;orderBy,
			'orderway' =&gt; $this-&gt;orderWay,
			'orderbydefault' =&gt; $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')],
			'orderwayposition' =&gt; $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')], // Deprecated: orderwayposition
			'orderwaydefault' =&gt; $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')],
			'stock_management' =&gt; (int)$stock_management));
	}
</pre>
<p>And paste it inside our new override:</p>
<pre class="brush: php; title: ; notranslate">
Class CategoryController extends CategoryControllerCore
{
	public function productSort()
	{
		// $this-&gt;orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby'));
		// $this-&gt;orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway'));
		// 'orderbydefault' =&gt; Tools::getProductsOrder('by'),
		// 'orderwayposition' =&gt; Tools::getProductsOrder('way'), // Deprecated: orderwayposition
		// 'orderwaydefault' =&gt; Tools::getProductsOrder('way'),

		$stock_management = Configuration::get('PS_STOCK_MANAGEMENT') ? true : false; // no display quantity order if stock management disabled
		$order_by_values = array(0 =&gt; 'name', 1 =&gt; 'price', 2 =&gt; 'date_add', 3 =&gt; 'date_upd', 4 =&gt; 'position', 5 =&gt; 'manufacturer_name', 6 =&gt; 'quantity', 7 =&gt; 'reference');
		$order_way_values = array(0 =&gt; 'asc', 1 =&gt; 'desc');
		$this-&gt;orderBy = Tools::strtolower(Tools::getValue('orderby', $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')]));
		$this-&gt;orderWay = Tools::strtolower(Tools::getValue('orderway', $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')]));
		if (!in_array($this-&gt;orderBy, $order_by_values))
			$this-&gt;orderBy = $order_by_values[0];
		if (!in_array($this-&gt;orderWay, $order_way_values))
			$this-&gt;orderWay = $order_way_values[0];

		$this-&gt;context-&gt;smarty-&gt;assign(array(
			'orderby' =&gt; $this-&gt;orderBy,
			'orderway' =&gt; $this-&gt;orderWay,
			'orderbydefault' =&gt; $order_by_values[(int)Configuration::get('PS_PRODUCTS_ORDER_BY')],
			'orderwayposition' =&gt; $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')], // Deprecated: orderwayposition
			'orderwaydefault' =&gt; $order_way_values[(int)Configuration::get('PS_PRODUCTS_ORDER_WAY')],
			'stock_management' =&gt; (int)$stock_management));
	}
}
</pre>
<p>We are almost done! Now pay a closer look at the <strong>$order_by_values</strong> variable. It&#8217;s an array containing all valid names for the &#8216;sort by&#8217; box! Therefore, at this point we can simply add <strong>sales</strong> to it, as a last item:</p>
<pre class="brush: php; title: ; notranslate">
	$order_by_values = array(0 =&gt; 'name', 1 =&gt; 'price', 2 =&gt; 'date_add', 3 =&gt; 'date_upd', 4 =&gt; 'position', 5 =&gt; 'manufacturer_name', 6 =&gt; 'quantity', 7 =&gt; 'reference', 8 =&gt; 'sales');
</pre>
<p>Do you now see why it is important to keep names uniform throughout all the code? Well, at this point we are done!</p>
<p>Go to <em>cache/</em> and delete <strong>class_index.php</strong>. Navigate to a category page and test out the form, it should order your products by sales, and preserve changes while navigating through pages!</p>
<p><strong>Important note:</strong> if you test out the new sorting options, be sure the orders for your tests <strong>are valid</strong>, as otherwise products bought will not add up to the quantity which is necessary to calculate the number of sales!</p>
<p>The post <a rel="nofollow" href="http://nemops.com/sort-by-sales-prestashop/">Adding a &#8216;sort by sales&#8217; option to Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/sort-by-sales-prestashop/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
