Does anyone know if there is a way to specify the sort order for featured products?
If not, in the source code, where is the code that actually fetch the featured products from database? (maybe I can simply add a sort by there to sort it?)
Thanks!
In /catalog/controller/extension/module/featured.php
Add something like:
http://screenshots.antropy.co.uk/8635c3 ... 510812.jpg
Add something like:
http://screenshots.antropy.co.uk/8635c3 ... 510812.jpg
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Somehow adding the said line does not work for me:
I saw this line early:
Do we know where does
come from? (maybe I can change the value there instead?)
Thank you!
Code: Select all
'sort' => 'name'
Code: Select all
$products = array_slice($setting['product'], 0, (int)$setting['limit']);
Code: Select all
$setting['product']
Thank you!
Last edited by straightlight on Sun Apr 12, 2020 11:09 pm, edited 2 times in total.
Reason: Added code tags.
Reason: Added code tags.
Actually I found this works for me:
In the said file, near end of it, add this to sort it:
In the said file, near end of it, add this to sort it:
Code: Select all
usort($data['products'], function($a, $b) {
return strcmp($a['name'], $b['name']);
});
Last edited by straightlight on Sun Apr 12, 2020 11:10 pm, edited 1 time in total.
Reason: Added code tags.
Reason: Added code tags.
I was looking for a quick solution to this issue myself.
The option I chose was to directly edit the order in the underlying data table of the database.
**!Ensure you backup your database before editing any table data!!** - You have been warned.
db - table
db > db_module
You can simply edit the order of the displayed product id's. You need the record where 'code' = 'featured'
You'll end up looking at something similar to the below JSON string:
the numbers string after 'product' is a list of the items to be displayed and in the order in which they are shown. Simply amend the order. Use your own preferred method e.g SQL statement, phpmyadmin etc.
This requires no edits to core OC files.
The option I chose was to directly edit the order in the underlying data table of the database.
**!Ensure you backup your database before editing any table data!!** - You have been warned.
db - table
db > db_module
You can simply edit the order of the displayed product id's. You need the record where 'code' = 'featured'
You'll end up looking at something similar to the below JSON string:
Code: Select all
{"name":"Home Page","product_name":"","product":["263","1492","1400","1402","1454","1469","1466","1421","342"],"limit":"12","width":"125","height":"175","status":"1"}
This requires no edits to core OC files.
Last edited by straightlight on Sun Apr 12, 2020 11:11 pm, edited 1 time in total.
Reason: Removed constant caps and added code tags.
Reason: Removed constant caps and added code tags.
Thanks for the info, was a easy and smooth solutionDS4A wrote: ↑Sun Apr 12, 2020 9:06 pmI was looking for a quick solution to this issue myself.
The option I chose was to directly edit the order in the underlying data table of the database.
**!Ensure you backup your database before editing any table data!!** - You have been warned.
db - table
db > db_module
You can simply edit the order of the displayed product id's. You need the record where 'code' = 'featured'
You'll end up looking at something similar to the below JSON string:the numbers string after 'product' is a list of the items to be displayed and in the order in which they are shown. Simply amend the order. Use your own preferred method e.g SQL statement, phpmyadmin etc.Code: Select all
{"name":"Home Page","product_name":"","product":["263","1492","1400","1402","1454","1469","1466","1421","342"],"limit":"12","width":"125","height":"175","status":"1"}
This requires no edits to core OC files.
Works nice on my v3.0.3.7 shop
Illustrator and Photoshop Expert - Knowledge in Html, CSS and Bootstrap, not very good at programing. Had plenty of years experience in Prestashop, but went over to Opencart
Who is online
Users browsing this forum: Bing [Bot], JessiesBoutique, pprmkr and 514 guests