Page 1 of 1

Sort/Filter By Date - Products

Posted: Sun Sep 23, 2012 9:54 am
by HATEPOLICY
Could anyone please advice on how to add Sort/Filter by date for products, front end, for the customers.

I tried searching the forums, no joy, tried extensions, nada also.

We just want to be able to add the option of sorting by date added, along with name, model & price,
I see there is reference to date_added amongst the masses of code, can this be applied to products also somehow?
Running 154.1.

Many thanks in advance.

Re: Sort/Filter By Date - Products

Posted: Sun Sep 23, 2012 10:41 am
by HATEPOLICY
Edit:
http://forum.opencart.com/viewtopic.php?f=20&t=56125

Could this post apply to product.php?

Thanks.

Re: Sort/Filter By Date - Products

Posted: Sat Nov 03, 2012 12:51 am
by ameliaa
I am looking for a solution for this too. Anyone?

Re: Sort/Filter By Date - Products

Posted: Mon Nov 05, 2012 10:05 am
by ameliaa
For those who need the solution. I got this from another programmer. This is a VQmod file: date_added_sort_order.xml

Code: Select all

<modification>
	
	<id>Display products by date added at frontend by default</id>
	<version>1.0.0</version>
	<vqmver>2.1</vqmver>
	<author>everthemes.com</author>
	
	<file name="catalog/controller/product/category.php">
		<operation>
			<search position="replace"><![CDATA[$sort = 'p.sort_order';]]></search>
			<add><![CDATA[
				$sort = 'p.date_added';
				]]></add>
		</operation>
		<operation>
			<search position="replace"><![CDATA[$order = 'ASC';]]></search>
			<add><![CDATA[
				$order = 'DESC';
				]]></add>
		</operation>
		<operation>
			<search position="replace"><![CDATA[p.sort_order-ASC]]></search>
			<add><![CDATA[
				p.date_added-DESC
				]]></add>
		</operation>
		<operation>
			<search position="replace"><![CDATA[p.sort_order&order=ASC]]></search>
			<add><![CDATA[
				p.date_added&order=DESC
				]]></add>
		</operation>
	</file>
	
</modification>

Re: Sort/Filter By Date - Products

Posted: Tue Feb 26, 2013 11:40 pm
by napok
Thanks ameliaa,
it works well.
Now the only down turn is that, if you try another sorting option like for instance price and then go back to default, it sorts everything alphabetically (that's default) but backwards- so Z-A.
Any idea to put the default option back in place? Just looks funny to have Z items first as default.
Alexandra

Re: Sort/Filter By Date - Products

Posted: Wed May 15, 2013 6:01 pm
by botonakis
Thank you ameliaa.

Re: Sort/Filter By Date - Products

Posted: Mon Nov 04, 2013 6:23 pm
by neocreo
That vqmod that Ameliaa posted did the trick - however, The sorting and filtering is also used on the search page, so Add on the same file operation for catalog/controller/product/search.php

Code: Select all

<file name="catalog/controller/product/search.php">
      <operation>
         <search position="replace"><![CDATA[$sort = 'p.sort_order';]]></search>
         <add><![CDATA[
            $sort = 'p.date_added';
            ]]></add>
      </operation>
      <operation>
         <search position="replace"><![CDATA[$order = 'ASC';]]></search>
         <add><![CDATA[
            $order = 'DESC';
            ]]></add>
      </operation>
      <operation>
         <search position="replace"><![CDATA[p.sort_order-ASC]]></search>
         <add><![CDATA[p.date_added-DESC]]></add>
      </operation>
      <operation>
         <search position="replace"><![CDATA[p.sort_order&order=ASC]]></search>
         <add><![CDATA[p.date_added&order=DESC]]></add>
      </operation>    
   </file>
Also, if you run into any problems with the sorting not working in the front end, just remove the white-space inside the CDATA and keep it on one line.

Re: Sort/Filter By Date - Products

Posted: Sat Nov 09, 2013 8:53 pm
by tolinho
Hi.
Thanks ameliaa and neocreo :)
You made my day!!

Re: Sort/Filter By Date - Products

Posted: Wed Nov 27, 2013 1:45 pm
by modernmagic
I have successfully created and installed the "date_added_sort_order.xml".

Is there a way to only have this only affect a specific category of products?

Re: Sort/Filter By Date - Products

Posted: Tue Apr 22, 2014 5:15 pm
by guldan
Yes, the same question! How to change the default sort for specific/certain category only?
I think we can use the path/category id, but I don't know where to put it. In model? In controller?
Please help :)

Re: Sort/Filter By Date - Products

Posted: Tue Apr 22, 2014 11:39 pm
by modernmagic
Guldan,

There appears to be NO support anymore. I asked in Nov 2013.

Re: Sort/Filter By Date - Products

Posted: Wed Apr 23, 2014 12:53 pm
by guldan
Hi modernmagic,
I've just created a new thread, and got a response that solve our problem :)
Check here:
http://forum.opencart.com/viewtopic.php?f=20&t=123925

Re: Sort/Filter By Date - Products

Posted: Mon May 25, 2015 9:48 am
by ozkiremitci
how to multi sort ?

example sort by date and quantity.
http://forum.opencart.com/viewtopic.php?f=20&t=145304

Re: Sort/Filter By Date - Products

Posted: Mon Oct 16, 2017 2:02 pm
by paddys_1
There is an OC Mod that changes the sort order to show items by the date added, so the most recent are displayed first.