The problem with the sorting of products
Posted: 18 May 2020, 12:21
I created a category and created several products in it.
When I try to set the order of products, it is not saved. It is also not displayed correctly in the frontend.
I opened the browser console and saw that the request is sent to the address:
'...administrator/index.php?option=com_phocacart&task=phocacartitems.saveOrderAjax&tmpl=component'
Here is the request body:
{"filter[search]":"","list[fullordering]":"pc.ordering+ASC","list[limit]":"20","filter[published]":"","filter[category_id]":"2","filter[language]":"","order[]":["1","2","3","4","5","6"],"cid[]":["10","7","9","10","8","11","12"],"limitstart":"0","batch[assetgroup_id]":"","batch[language_id]":"","batch[category_id]":"","batch[move_copy]":"m","batch[copy_all_cats]":"0","batch[skip_creating_unique_name]":"0","batch[copy_download_files]":"0","batch[copy_attributes_download_files]":"0","copy_attributes":"","copy_attributes_download_files":"0","boxchecked":"1","c09de0f5a69192bc1533528f3f01bbfb":"1","original_order_values":""}
I found the saveOrderAjax() function in "controllers/phocacartcommons.php"
I replaced the string
(41) if ($return) { echo "1";}
with the string
if ($return) { print_r($pks);}
or the string
if ($return) { print_r($order);}
Now I see the answer in the console:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
or
Array ( [0] => 7 [1] => 9 [2] => 10 [3] => 8 [4] => 11 [5] => 12 )
This way data is correctly received and sent to the function "saveorder($pks = null, $order = null)" in the file models/phocacartitem.php
The Function should save data to the "#_phocacart_product_categories " table - but nothing is saved!
What could be the error?
P.S.
I manually changed the order of products in the category via phpMyAdmin - everything was displayed correctly in the admin panel and on the site. It seems that the problem is in the function "saveorder($pks = null, $order = null)" in the file models/phocacartitem.php
When I try to set the order of products, it is not saved. It is also not displayed correctly in the frontend.
I opened the browser console and saw that the request is sent to the address:
'...administrator/index.php?option=com_phocacart&task=phocacartitems.saveOrderAjax&tmpl=component'
Here is the request body:
{"filter[search]":"","list[fullordering]":"pc.ordering+ASC","list[limit]":"20","filter[published]":"","filter[category_id]":"2","filter[language]":"","order[]":["1","2","3","4","5","6"],"cid[]":["10","7","9","10","8","11","12"],"limitstart":"0","batch[assetgroup_id]":"","batch[language_id]":"","batch[category_id]":"","batch[move_copy]":"m","batch[copy_all_cats]":"0","batch[skip_creating_unique_name]":"0","batch[copy_download_files]":"0","batch[copy_attributes_download_files]":"0","copy_attributes":"","copy_attributes_download_files":"0","boxchecked":"1","c09de0f5a69192bc1533528f3f01bbfb":"1","original_order_values":""}
I found the saveOrderAjax() function in "controllers/phocacartcommons.php"
I replaced the string
(41) if ($return) { echo "1";}
with the string
if ($return) { print_r($pks);}
or the string
if ($return) { print_r($order);}
Now I see the answer in the console:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 )
or
Array ( [0] => 7 [1] => 9 [2] => 10 [3] => 8 [4] => 11 [5] => 12 )
This way data is correctly received and sent to the function "saveorder($pks = null, $order = null)" in the file models/phocacartitem.php
The Function should save data to the "#_phocacart_product_categories " table - but nothing is saved!
What could be the error?
P.S.
I manually changed the order of products in the category via phpMyAdmin - everything was displayed correctly in the admin panel and on the site. It seems that the problem is in the function "saveorder($pks = null, $order = null)" in the file models/phocacartitem.php