- Posts: 63
- Thank you received: 1
Ordering download files
-- HikaShop version -- : 2.3.2
-- Joomla version -- : 3.3
-- PHP version -- : 5.4
Hello,
For a downloadable product that has several files to be downloaded, is it possible to sort the download files so that they appear alphabetically? Right now they seem to be in almost random order and I can't find any way to order them (see attachment).
Thanks in advance!
Andre
Please Log in or Create an account to join the conversation.
The product files are sorted by "file_ordering" and then by "file_id".
If you want to change the sorting, you will have to edit a core file (not really recommended) or to use a view override to change the sorting before the display of the list.
In the view "backend | your_backend_temple | product | file" you will find the code which display the list of product files.
The easier will be to re-generate the file list before the display.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
In the view "backend | your_backend_temple | product | file"
What do you mean by "view"? Are you talking about Joomla menus? Or Hikashop menus? Or ftp file structure? Or database structure?
The easier will be to re-generate the file list before the display.
What do you mean by that? To replace some code in the file with the code you have given?
Please Log in or Create an account to join the conversation.
One basic in HikaShop is the view override.
www.hikashop.com/support/support/documen...ize-the-display.html
www.hikashop.com/support/documentation/i...op-view-listing.html
It allows you to customize HikaShop without editing core file, so you can update HikaShop without loosing your modifications.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
When you have to replace some code, I mention the code before and the code after.
The code I gave you is a piece of code you have to add in the view ; before the display ; which means : at the beginning of the file.
Is it more clear ?
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
When you write "at the beginning of the file" I assume you mean after the initial <?php , correct?
Still, when I add your code, it completely messes up the backend display so that Joomla becomes inoperable. And the notification email continues to display the download links in an apparently random order (see attached). How to order them alphabetically?
Andre
Please Log in or Create an account to join the conversation.
Thanks to use that code:
Please Log in or Create an account to join the conversation.
The download links are still disorganized and apparently in random order, either when looking at the product in the back end, or also in the customer notification email.
Still hoping for a solution.
Please Log in or Create an account to join the conversation.
I can see that you didn't enter any name for the files in your first screenshot, so it's normal that the code of Xavier doesn't do anything.
Instead, use that code:
For the customer emails, you need to change the line:
$query = 'SELECT a.* FROM '.hikashop_table('file').' AS a WHERE '.implode(' AND ',$filters).' ORDER BY file_ref_id ASC, file_ordering ASC';
to:
$query = 'SELECT a.* FROM '.hikashop_table('file').' AS a WHERE '.implode(' AND ',$filters).' ORDER BY file_ref_id ASC, file_path ASC, file_ordering ASC';
in the file administrator/components/com_hikashop/classes/order.php
Please Log in or Create an account to join the conversation.
However, changing the line in order.php did not fix the order of the downloads in the notification email. They are still disordered.
Please Log in or Create an account to join the conversation.
There was a second query on line 905 of order.php which I changed to
$query = 'SELECT b.*,a.* FROM '.hikashop_table('file').' AS a LEFT JOIN '.hikashop_table('download').' AS b ON b.order_id='.$order->order_id.' AND a.file_id = b.file_id WHERE '.implode(' AND ',$filters).' ORDER BY file_ref_id ASC, file_path ASC, file_ordering, file_pos ASC';
Thank you!
Please Log in or Create an account to join the conversation.
To come back to an old post: I was wondering if it were possible to add the fixes above in a future update of Hikashop, so that the download files are always ordered in both the backend and in the confirmation email? It is rather tedious to have to go back and to change the core files every time Hikashop is updated.
Thanks!
Andre
Please Log in or Create an account to join the conversation.
The files are ordered based on their file_ordering. Actually the interface doesn't allow you to set the ordering of the files, only the images. That's something we want to support in one of the next versions of HikaShop.
So we can't add that "fix" as it will break the sorting by the ordering of the files.
Please Log in or Create an account to join the conversation.
Thanks,
Please Log in or Create an account to join the conversation.
I'm sorry but it is possible to change the ordering of product files.
You can drag'n'drop the product files like you can drag'n'drop the product images.
So, I'm afraid that the feature is already there.
And you can also see in the changelog that HikaShop 2.6.2 include a little fix for the product file ordering saving.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Okay, I see.
In the HikaShop order class, the product files are loaded and added in the order object.
That is mostly done by the function "_setDownloadFile".
You can see to replace how the variable $id is generated ; from
You will find the loop
Thus, you should get the same ordering in the loaded order than the ordering set in the products.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
In the HikaShop order class, the product files are loaded and added in the order object.
That is mostly done by the function "_setDownloadFile".
I don't understand this answer. What is the "HikaShop order class" and what is the function "_setDownloadFile"?
Please Log in or Create an account to join the conversation.
The HikaShop order class is the file administrator/components/com_hikashop/classes/order.php
There, you'll find the function _setDownloadFile near line 1600
Note that a more complete patch has been added by Jerome to HikaShop 3.0.0 for that, so if you're on HikaShop 3.0.0, that patch shouldn't be needed.
Please Log in or Create an account to join the conversation.