- Posts: 45
- Thank you received: 0
Sort by product code
- Squashtoppertje
-
Topic Author
- Offline
Less
More
10 years 10 months ago - 10 years 10 months ago #221649
by Squashtoppertje
Sort by product code was created by Squashtoppertje
-- HikaShop version -- : 2.6.0. Business
Hi,
I have set a menu to show the products and sort them by product_code. However this results in sorting like:
1
100
1000
1001
105
106
2
Where I would like it to sort numeric like:
1
2
100
105
106
1000
1001
How can I change this?
Thanks!
Hi,
I have set a menu to show the products and sort them by product_code. However this results in sorting like:
1
100
1000
1001
105
106
2
Where I would like it to sort numeric like:
1
2
100
105
106
1000
1001
How can I change this?
Thanks!
Last edit: 10 years 10 months ago by Squashtoppertje.
Please Log in or Create an account to join the conversation.
10 years 10 months ago #221655
by nicolas
Replied by nicolas on topic Sort by product code
Hi,
As the product_code is a text field, the sorting is done alphabetically, character by character and thus 100 comes before 2.
Either add trailing zeros so that all the product_codes have the same number of characters, or change the product_code column type to integer in the hikashop_product table of your database via your phpmyadmin and that will do what you want.
As the product_code is a text field, the sorting is done alphabetically, character by character and thus 100 comes before 2.
Either add trailing zeros so that all the product_codes have the same number of characters, or change the product_code column type to integer in the hikashop_product table of your database via your phpmyadmin and that will do what you want.
The following user(s) said Thank You: Squashtoppertje
Please Log in or Create an account to join the conversation.
- Squashtoppertje
-
Topic Author
- Offline
Less
More
- Posts: 45
- Thank you received: 0
10 years 10 months ago #221813
by Squashtoppertje
Replied by Squashtoppertje on topic Sort by product code
Hi Nicolas,
Well, changing it to "integer" seemed the easiest solution, but this wasn't the case. I found out that if you duplicate a product the product_code gets some text attached, xxx-copyxxx. Because this field is an integer now, the data can not be stored, which results in removal of both products! Auch...
Is there a way to get around this?
(If I use trailing zero's then I need to remove all products before importing, because the poduct_code is needed to match the import with the product. I'd rather not delete all products).
Thanks.
Well, changing it to "integer" seemed the easiest solution, but this wasn't the case. I found out that if you duplicate a product the product_code gets some text attached, xxx-copyxxx. Because this field is an integer now, the data can not be stored, which results in removal of both products! Auch...
Is there a way to get around this?
(If I use trailing zero's then I need to remove all products before importing, because the poduct_code is needed to match the import with the product. I'd rather not delete all products).
Thanks.
Please Log in or Create an account to join the conversation.
10 years 10 months ago #221825
by nicolas
Replied by nicolas on topic Sort by product code
Hi,
You can change the line:
$newProduct->product_code = $this->template->product_code.'_copy'.rand();
to:
$newProduct->product_code = $this->template->product_code.rand();
in the file administrator/components/com_hikashop/helpers/import.php and that will allow you to copy the products even if the product_code is an integer.
You can change the line:
$newProduct->product_code = $this->template->product_code.'_copy'.rand();
to:
$newProduct->product_code = $this->template->product_code.rand();
in the file administrator/components/com_hikashop/helpers/import.php and that will allow you to copy the products even if the product_code is an integer.
Please Log in or Create an account to join the conversation.
Time to create page: 0.231 seconds