[Skip to main content](#vessel-content)

#   Display order of images.

##

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile") Topic Author
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

15 years 10 months ago [\#4623](#4623) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  *[Display order of images.](/forum/4-how-to/4623-display-order-of-images#4623 "Hikashop 1.4.2, Joomla 1.6 Imported a number of products each with several images. Images appear to be displayed in descending ID order. I.E. the most recent image appears as the default. Could this be changed to make images appear in the order in which they are added / listed in the import CSV file?")* was created by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")*

Hikashop 1.4.2, Joomla 1.6
Imported a number of products each with several images.
Images appear to be displayed in descending ID order.
I.E. the most recent image appears as the default.
Could this be changed to make images appear in the order in which they are added / listed in the import CSV file?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQ2MjMtZGlzcGxheS1vcmRlci1vZi1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86560
- Thank you received: 14307
-
-

15 years 10 months ago [\#4628](#4628) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Display order of images.](/forum/4-how-to/4623-display-order-of-images#4628 "Hikashop 1.4.2, Joomla 1.6 Imported a number of products each with several images. Images appear to be displayed in descending ID order. I.E. the most recent image appears as the default. Could this be changed to make images appear in the order in which they are added / listed in the import CSV file?")*

Mmm. The images as well as anything else in the CSV should be entered in the same order you entered them.
If you activate the debug mode of joomla and that you try again, could you check on the query on the table hikashop_files ?
Normally, the files in there should be in the same order as you entered them.
If that's the case, then, it means that mysql might be inserting them in reverse order...In which case we will have to reverse the array of files before building the query.
If that's not the case, then maybe there is a bug in hikashop. Funny enough though you should be able to fix that with the same change: reverse the array of files.

For that, in the function _insertFiles(&amp;$products,$type='files') of the file administrator/components/com_hikashop/helpers/import.php you can add the code:
$values = array_reverse($values);
just before the code
$this-&gt;db-&gt;setQuery($insert.implode('),(',$values).')');

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQ2MjMtZGlzcGxheS1vcmRlci1vZi1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile") Topic Author
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

15 years 10 months ago [\#4654](#4654) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Re: Display order of images.](/forum/4-how-to/4623-display-order-of-images#4654 "Hikashop 1.4.2, Joomla 1.6 Imported a number of products each with several images. Images appear to be displayed in descending ID order. I.E. the most recent image appears as the default. Could this be changed to make images appear in the order in which they are added / listed in the import CSV file?")*

(a) In the product screen the query looks like this (some places with IN other places with ![=)](/smile.gif "=)"):

> SELECT \*
> FROM saj\_hikashop\_file
> WHERE file\_ref\_id IN (142)
> AND file\_type = 'product'

Could it be changed to:

> SELECT \*
> FROM saj\_hikashop\_file
> WHERE file\_ref\_id IN (142)
> AND file\_type = 'product'
> ORDER BY file\_id ASC

(b) In the category product listing screen the query looks like this:

> SELECT a.\*,b.\*
> FROM saj\_hikashop\_category AS a
> LEFT JOIN saj\_hikashop\_file AS b
> ON a.category\_id=b.file\_ref\_id
> AND b.file\_type='category'
> WHERE a.category\_id = 1
> LIMIT 1

Could it be changed to:

> SELECT a.\*,b.\*
> FROM saj\_hikashop\_category AS a
> LEFT JOIN saj\_hikashop\_file AS b
> ON a.category\_id=b.file\_ref\_id
> AND b.file\_type='category'
> WHERE a.category\_id = 1
> ORDER BY b.file\_id ASC
> LIMIT 1

For (a) I could solve this in the product template by running my own PHP sort function over '$this-&gt;element-&gt;images'.

For (b) looks like it would be more work in the category template as I would have to write my own query.

Without the ORDER BY is relying on the database engine implementation as to which is the first and may change with different versions / engines.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQ2MjMtZGlzcGxheS1vcmRlci1vZi1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86560
- Thank you received: 14307
-
-

15 years 10 months ago [\#4666](#4666) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Re: Display order of images.](/forum/4-how-to/4623-display-order-of-images#4666 "Hikashop 1.4.2, Joomla 1.6 Imported a number of products each with several images. Images appear to be displayed in descending ID order. I.E. the most recent image appears as the default. Could this be changed to make images appear in the order in which they are added / listed in the import CSV file?")*

Hi,

Great, so that means that the problem isn't in the import but in the SELECT query.
An order by on the file info loading query would indeed be great.

The query you talk about in b isn't the query loading the product images but the query loading the categories image. As there is only one image per category, this is not needed.
The query for both the product page and the products listing is actually the same.

If you change the file components/com_hikashop/views/product/view.html.php by the one in that package, that should fix the problem. That will of course be included in next version.

####  *This attachment is hidden for guests.
Please log in or register to see it.*

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQ2MjMtZGlzcGxheS1vcmRlci1vZi1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[brainforge](/forum/user/423-brainforge "View brainforge's Profile")**
- [![brainforge's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar423.jpg)](/forum/user/423-brainforge "View brainforge's Profile") Topic Author
- [ Offline](/forum/user/423-brainforge)

Less More

- Posts: 298
- Thank you received: 5
-
-
-
- [](https://brainforge.co.uk)
-

15 years 10 months ago [\#4670](#4670) by [brainforge](/forum/user/423-brainforge "View brainforge's Profile")  Replied by *[brainforge](/forum/user/423-brainforge "View brainforge's Profile")* on topic *[Re: Display order of images.](/forum/4-how-to/4623-display-order-of-images#4670 "Hikashop 1.4.2, Joomla 1.6 Imported a number of products each with several images. Images appear to be displayed in descending ID order. I.E. the most recent image appears as the default. Could this be changed to make images appear in the order in which they are added / listed in the import CSV file?")*

Thanks.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzQ2MjMtZGlzcGxheS1vcmRlci1vZi1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.045 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
