Hello
How can I sort downloads by the date the file was added? There is no sorting option, which means the files are very scattered. I have Opencart 4.1.0.0.
Thank you
How can I sort downloads by the date the file was added? There is no sorting option, which means the files are very scattered. I have Opencart 4.1.0.0.
Thank you
Last edited by sylwekb on Tue Mar 04, 2025 9:02 pm, edited 1 time in total.
Have you checked the marketplace?
Most developers recommend not to use OC4 as you know so if you can not find an extension for OC4 you might find one for an earlier OC version and edit it yourself or hire a developer.
You can also search google and adapt the information to suit
https://www.google.com/search?q=opencar ... data+added
Most developers recommend not to use OC4 as you know so if you can not find an extension for OC4 you might find one for an earlier OC version and edit it yourself or hire a developer.
You can also search google and adapt the information to suit
https://www.google.com/search?q=opencar ... data+added
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
SOLVED!
Go to catalog/model/account/download.php
replace
Go to catalog/model/account/download.php
Code: Select all
$query = $this->db->query("SELECT DISTINCT `d`.`download_id`, `o`.`order_id`, `o`.`date_added`, `dd`.`name`, `d`.`filename` FROM `" . DB_PREFIX . "order` `o` LEFT JOIN `" . DB_PREFIX . "order_product` `op` ON (`o`.`order_id` = `op`.`order_id`) LEFT JOIN `" . DB_PREFIX . "product_to_download` `p2d` ON (`op`.`product_id` = `p2d`.`product_id`) LEFT JOIN `" . DB_PREFIX . "download` `d` ON (`p2d`.`download_id` = `d`.`download_id`) LEFT JOIN `" . DB_PREFIX . "download_description` `dd` ON (`d`.`download_id` = `dd`.`download_id`) WHERE `o`.`customer_id` = '" . (int)$this->customer->getId() . "' AND `o`.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND (" . implode(" OR ", $implode) . ") AND `dd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `dd`.`name` DESC LIMIT " . (int)$start . "," . (int)$limit);
replace
Code: Select all
$query = $this->db->query("SELECT DISTINCT `d`.`download_id`, `o`.`order_id`, `o`.`date_added`, `dd`.`name`, `d`.`filename` FROM `" . DB_PREFIX . "order` `o` LEFT JOIN `" . DB_PREFIX . "order_product` `op` ON (`o`.`order_id` = `op`.`order_id`) LEFT JOIN `" . DB_PREFIX . "product_to_download` `p2d` ON (`op`.`product_id` = `p2d`.`product_id`) LEFT JOIN `" . DB_PREFIX . "download` `d` ON (`p2d`.`download_id` = `d`.`download_id`) LEFT JOIN `" . DB_PREFIX . "download_description` `dd` ON (`d`.`download_id` = `dd`.`download_id`) WHERE `o`.`customer_id` = '" . (int)$this->customer->getId() . "' AND `o`.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND (" . implode(" OR ", $implode) . ") AND `dd`.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `o`.`date_added` DESC LIMIT " . (int)$start . "," . (int)$limit);
Last edited by sylwekb on Tue Mar 04, 2025 10:54 pm, edited 1 time in total.
Great well done - thank you for posting your solution.
Thank you for adding [SOLVED] to the title
If you would be so kind as to use the </> mark up when posting code.
Highlight the first first part of the code and press the </> button in the button bar.
Do the same for the second (replacement) code
For anyone wishing to understand
Customer Account Downloads are not ordered randomly they are ordered by name
THIS => ORDER BY `dd`.`name
The user wanted it ordered by date added
THIS => ORDER BY `o`.`date_added`
What is written above is basically to replace the ORDER BY from name to date_added
The references dd and o are shorthand table names
If you look at the code you can see that they are shortened by
THIS => DB_PREFIX . "download_description` `dd`
THIS => DB_PREFIX . "order` `o`
Thank you for adding [SOLVED] to the title
If you would be so kind as to use the </> mark up when posting code.
Highlight the first first part of the code and press the </> button in the button bar.
Do the same for the second (replacement) code
For anyone wishing to understand
Customer Account Downloads are not ordered randomly they are ordered by name
THIS => ORDER BY `dd`.`name
The user wanted it ordered by date added
THIS => ORDER BY `o`.`date_added`
What is written above is basically to replace the ORDER BY from name to date_added
The references dd and o are shorthand table names
If you look at the code you can see that they are shortened by
THIS => DB_PREFIX . "download_description` `dd`
THIS => DB_PREFIX . "order` `o`
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Who is online
Users browsing this forum: No registered users and 15 guests