[Skip to main content](#vessel-content)

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

##

- **[dyvel](/forum/user/39996-dyvel "View dyvel's Profile")**
- [![dyvel's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/39996-dyvel "View dyvel's Profile") Topic Author
- [ Offline](/forum/user/39996-dyvel)

Less More

- Posts: 88
- Thank you received: 20
-
-

5 years 2 months ago [\#335586](#335586) by [dyvel](/forum/user/39996-dyvel "View dyvel's Profile")  *[  [ ![akeeba&#95;1683898904](/media/com_hikashop/upload/thumbnails/100x100/akeeba_1683898904.png) ](/marketplace/integration/product/233-akeeba-subscriptions "Akeeba subscriptions")

Free    [ Akeeba subscriptions ](/marketplace/integration/product/233-akeeba-subscriptions)                        ](/forum/31-development/903175-products-order-for-inserted-products-in-articles-simple-solution-provided#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: &lt;div id=")*

[ ![shipstation-logo-free](/media/com_hikashop/upload/thumbnails/100x100/shipstation-logo-free.png) ](/marketplace/shipping/product/232-shipstation "Shipstation (legacy)")

Free    [ Shipstation (legacy) ](/marketplace/shipping/product/232-shipstation)

[ ![](/media/com_hikashop/upload/thumbnails/100x100/hikaserial-subscription-renewal.png) ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services "HikaSubscription Update, support and services")

€ 50,00     [ HikaSubscription Update, support and services ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services)                      [ Choose options ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services)

[ ![product-orders-history](/media/com_hikashop/upload/thumbnails/100x100/product-orders-history.png) ](/marketplace/operations/product/254-product-order-history "Product order history")

Free    [ Product order history ](/marketplace/operations/product/254-product-order-history)

[ ](/hikashop-menu-for-brands-listing/product/239-hikasubscription-update-support-and-services-two-years "HikaSubscription Update, support and services: Two years")

€ 90,00     [ HikaSubscription Update, support and services: Two years ](/hikashop-menu-for-brands-listing/product/239-hikasubscription-update-support-and-services-two-years)                  [Add to cart](/component/hikashop/product/updatecart/add-1/cid-239?Itemid=208)

To order by the order of ids, I modified the file: plugins/system/hikashopproductinsert/hikashopproductinsert.php in line 279: Change: To this: Now the order is respected. I hope you will consider adding this to the plugin for the next update? Have a nice day." class="hasTooltip topictitle"&gt;Products order for inserted products in articles (simple solution provided) was created by *[dyvel](/forum/user/39996-dyvel "View dyvel's Profile")*

-- 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:
[ ![akeeba&#95;1683898904](/media/com_hikashop/upload/thumbnails/100x100/akeeba_1683898904.png) ](/marketplace/integration/product/233-akeeba-subscriptions "Akeeba subscriptions")

Free    [ Akeeba subscriptions ](/marketplace/integration/product/233-akeeba-subscriptions)

[ ![shipstation-logo-free](/media/com_hikashop/upload/thumbnails/100x100/shipstation-logo-free.png) ](/marketplace/shipping/product/232-shipstation "Shipstation (legacy)")

Free    [ Shipstation (legacy) ](/marketplace/shipping/product/232-shipstation)

[ ![](/media/com_hikashop/upload/thumbnails/100x100/hikaserial-subscription-renewal.png) ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services "HikaSubscription Update, support and services")

€ 50,00     [ HikaSubscription Update, support and services ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services)                      [ Choose options ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services)

[ ![product-orders-history](/media/com_hikashop/upload/thumbnails/100x100/product-orders-history.png) ](/marketplace/operations/product/254-product-order-history "Product order history")

Free    [ Product order history ](/marketplace/operations/product/254-product-order-history)

[ ](/hikashop-menu-for-brands-listing/product/239-hikasubscription-update-support-and-services-two-years "HikaSubscription Update, support and services: Two years")

€ 90,00     [ HikaSubscription Update, support and services: Two years ](/hikashop-menu-for-brands-listing/product/239-hikasubscription-update-support-and-services-two-years)                  [Add to cart](/component/hikashop/product/updatecart/add-1/cid-239?Itemid=208)

To order by the order of ids, I modified the file: plugins/system/hikashopproductinsert/hikashopproductinsert.php
in line 279:

Change: Code:

$product_query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_id IN (' . implode(',', $ids) . ') AND product_access='.$db-&gt;quote('all').' AND product_published=1';

To this: Code:

$product_query = 'SELECT * FROM ' . hikashop_table('product') . ' WHERE product_id IN (' . implode(',', $ids) . ') AND product_access='.$db-&gt;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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50LzkwMzE3NS1wcm9kdWN0cy1vcmRlci1mb3ItaW5zZXJ0ZWQtcHJvZHVjdHMtaW4tYXJ0aWNsZXMtc2ltcGxlLXNvbHV0aW9uLXByb3ZpZGVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86363
- Thank you received: 14296
-
-

5 years 1 month ago [\#335608](#335608) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[  [ ![akeeba&#95;1683898904](/media/com_hikashop/upload/thumbnails/100x100/akeeba_1683898904.png) ](/marketplace/integration/product/233-akeeba-subscriptions "Akeeba subscriptions")

Free    [ Akeeba subscriptions ](/marketplace/integration/product/233-akeeba-subscriptions)                        ](/forum/31-development/903175-products-order-for-inserted-products-in-articles-simple-solution-provided#335608 "-- 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: &lt;div id=")*

[ ![shipstation-logo-free](/media/com_hikashop/upload/thumbnails/100x100/shipstation-logo-free.png) ](/marketplace/shipping/product/232-shipstation "Shipstation (legacy)")

Free    [ Shipstation (legacy) ](/marketplace/shipping/product/232-shipstation)

[ ![](/media/com_hikashop/upload/thumbnails/100x100/hikaserial-subscription-renewal.png) ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services "HikaSubscription Update, support and services")

€ 50,00     [ HikaSubscription Update, support and services ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services)                      [ Choose options ](/hikashop-menu-for-brands-listing/product/237-hikasubscription-update-support-and-services)

[ ![product-orders-history](/media/com_hikashop/upload/thumbnails/100x100/product-orders-history.png) ](/marketplace/operations/product/254-product-order-history "Product order history")

Free    [ Product order history ](/marketplace/operations/product/254-product-order-history)

[ ](/hikashop-menu-for-brands-listing/product/239-hikasubscription-update-support-and-services-two-years "HikaSubscription Update, support and services: Two years")

€ 90,00     [ HikaSubscription Update, support and services: Two years ](/hikashop-menu-for-brands-listing/product/239-hikasubscription-update-support-and-services-two-years)                  [Add to cart](/component/hikashop/product/updatecart/add-1/cid-239?Itemid=208)

To order by the order of ids, I modified the file: plugins/system/hikashopproductinsert/hikashopproductinsert.php in line 279: Change: To this: Now the order is respected. I hope you will consider adding this to the plugin for the next update? Have a nice day." class="hasTooltip topictitle"&gt;Products order for inserted products in articles (simple solution provided)

Hi,

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMxLWRldmVsb3BtZW50LzkwMzE3NS1wcm9kdWN0cy1vcmRlci1mb3ItaW5zZXJ0ZWQtcHJvZHVjdHMtaW4tYXJ0aWNsZXMtc2ltcGxlLXNvbHV0aW9uLXByb3ZpZGVkP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.046 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
