Products order for inserted products in articles (simple solution provided)

  • Posts: 88
  • Thank you received: 19
2 years 6 months ago #335586

-- 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.

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

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
2 years 6 months ago #335608

Hi,

Yes, we can add that modification.
Thanks for your feedback and contribution.

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

Time to create page: 0.045 seconds
Powered by Kunena Forum