Sorting Error for product codes >= 100

  • Posts: 24
  • Thank you received: 1
7 years 2 months ago #289146

-- HikaShop version -- : 3.3.0
-- Joomla version -- : 3.8.5
-- PHP version -- : 7.0.18
-- Browser(s) name and version -- : Chrome 64.0.3282.186

Product codes over 100 do not sort correctly.
Mass actions and sorting do not consider any values greater than or equal to 100 as being greater than 99.
Instead, it considers 100 as being equal to 0.

This is easy to test.
Just create a product with the code of 100 and a couple of products with codes less than 100 and see how it sorts incorrectly.

Hoping this is an easy issue to fix. :blink:

Please Log in or Create an account to join the conversation.

  • Posts: 83778
  • Thank you received: 13564
  • MODERATOR
7 years 2 months ago #289150

Hi,

I'm sorry but it is not clear.
Please provide precise information.
Did you configure the "ordering column" of your menu item to "product_code" ?
Or are you using filters to sort the products ? In that case, how did you configure the filter ? Could you provide a screenshot of its settings ?
Also note that if you try to order the product listing based on the product_code column, it's normal that 100 is smaller than 99 since the product_code column is a VARCHAR (meaning that you can enter letters, not only numbers) and thus the sorting is done alphabetically, letter by letter, and first letter of 99, 9, is higher than the first letter of 100, 1.
You would have to change the type of that column to "integer" instead in the hikashop_product via your phpmyadmin if you want to have an ordering done as numbers and not as text.

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 1
7 years 2 months ago #289326

Hi,

That was the exact answer I was looking for.

Thank you :)

Please Log in or Create an account to join the conversation.

  • Posts: 24
  • Thank you received: 1
7 years 2 months ago #289328

The product_code column is already using alpha characters in many of the products, so changing the data type to integer is not an option.

Will it work if I create a custom field then set it column type to integer in my database and use that to sort the products on the front-end?

Attachments:
Last edit: 7 years 2 months ago by pcomelearning. Reason: Term clarity

Please Log in or Create an account to join the conversation.

  • Posts: 83778
  • Thank you received: 13564
  • MODERATOR
7 years 2 months ago #289347

Hi,

Yes, you can do that.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
7 years 2 months ago #289351

Hi,

I'd think that adding zeros in front of product codes beginning with < 100 should also do. Like so:
001...
002...
003...
...
010...
011...
...
099...
100...


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum