-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.10.1
-- PHP version -- : 7.4
Hi
Often, when I use the hikashopproductinsert plugin to insert products in articles, I need the products to be in a specific order - as in the order I add the ids, but as of now, the order is not respected in the query (it's missing an order by).
Just for reference, I insert products like this:
{product 233|236|232|237|254|239|name|link|picture|border|pricedis3|cart}
To order by the order of ids, I modified the file: plugins/system/hikashopproductinsert/hikashopproductinsert.php
in line 279:
Change:
$product_query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_id IN (' . implode(',', $ids) . ') AND product_access='.$db->quote('all').' AND product_published=1';
To this:
$product_query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_id IN (' . implode(',', $ids) . ') AND product_access='.$db->quote('all').' AND product_published=1 ORDER BY FIELD(product_id, ' . implode(',', $ids) . ')';
Now the order is respected.
I hope you will consider adding this to the plugin for the next update?
Have a nice day.