Sorted by date of receipt opencart
Adding sorting by novelty and other types of sorting in the online store opencart.
πŸ’Ό Creation of modern websites of any complexity. | πŸ‘Œ WEB-UKRAINE.COM

Sorted by date of receipt opencart

5/51 rating

Greetings to the distinguished visitor on the pages of our website. Today, in this article, we'll look at an example of how to change the sorting of goods in the opencart window.

Sorting products in the category opencart does not always suit the user, and often when creating an online store clients want to change the sorting that is by default to some sort of sorting, for example, in order for the product to be sorted by novelty, that is, by the date of receipt, here we will consider this example in this article, namely, we will sort in the category opencart by novelty.

I want to note that this example of changing the sorting of goods is suitable not only for the category page, but for other pages where there is the possibility of choosing sorting, this is search, producers. shares and so on ...

And since I change the sorting of the display of goods in the OpenCart category, what is needed for this?!

And you just need to make changes to the file /catalog/controller/product/category.php and also to the language file /catalog/language/russian/product/category.php.

If you are doing sorting of goods for other pages then the files need to be changed accordingly those that are responsible for the data of the pages, for example if you change the sorting on the manufacturers page then you change the file /catalog/controller/product/manufacturer.php, well, I think everything here is clear .

Let's consider what there are options for sorting goods in opencart:

  • ‘p.sort_order’, – sorting goods, by default.
  • ‘p.date_added’ – sorting goods by date of receipt.
  • ‘p.price’, – sorting of goods by price.
  • ‘pd.name’, – sorting of goods by name.
  • ‘p.model’, – sorting of goods by model.
  • ‘p.quantity’, – sorting of goods by quantity.
  • ‘rating’, – sorting goods by rating.

DESC - sorting of goods in ascending order,
ASC - sorting of goods in descending order.

These sort values can be used at your discretion depending on what kind of sorting of goods you are interested in. We are also interested in the particular 'p.date_added' since you remember that I originally wrote that for an example we will do sorting by the date of receipt of goods, that is, by novelties.



 
And so proceed and first of all change the sorting to sort by the date of receipt by default.

As I wrote earlier, I need to make changes to the file /catalog/controller/product/category.php, open it for editing by your favorite editor, I personally always use notepad ++.

At the beginning of this file, we find a piece of this code:

And in it we need to change:

And also to change the order of output of the list of goods (Ascending / Ascending), change the value:

DESC - new goods on top, then old ones,
ASC - old goods on top then sweat.

That's all, you changed the sorting of the default goods by novelty, now you have the goods listed in the list of goods first which you last added and then those that were added later will go.




 
The next item I suggest you to add to the drop-down list of sorting selection is the ability of the user to select the sort he needs in this case, as you remember, we are talking about sorting by the date of receipt.

Again, open the file /catalog/controller/product/category.php or if you have not closed it yet, then we remain in it and continue to make changes.

We find the code section:

And immediately after this code we add the following code:

All this file can be safely closed. But we still have one file for the changes it is /catalog/language/russian/product/category.php in it we need to specify the names (text) that will be displayed in the sorting drop-down list.

Add the following lines to the specified language file:

Well, in principle, and all that needed to be done to change the sorting of goods in the online store opencart.

I think the article will be useful to you, if this is so I will be happy to assess the top of the page or comment!

You may also like

No Comment

You can post first response comment.

Leave a Reply

Π’ΠΈΠ±Π΅Ρ€Ρ–Ρ‚ΡŒ спосіб спілкування
Звязатися Π· Π½Π°ΠΌΠΈ!
Ми Π³ΠΎΡ‚ΠΎΠ²Ρ– Π΄ΠΎ Π΄Ρ–Π°Π»ΠΎΠ³Ρƒ.