How to stop product tags defaulting to alphabetical order

The information on product pages I have are imported to database by a script, i.e. the title, the description and the products tags. This information comes from the metadata of images. However if an image has the tags in this order;

  1. pineapple
  2. apple
  3. pen

they appear on the product page (and in database) in alphabetical order i.e.

  1. apple
  2. pen
  3. pineapple

I need the tags in the original order. Is this there something I can do in the mysql database to keep the tags in original order and not in alphabetical order?

Any insight at all of this matter would be highly appreciated.

If the import script inserts the tags in the right order, and each tags is given some autoincrement-style ID, then you can use that in an order by clause in the SQL statement that grabs them for your product page.

If the import script doesn’t preserve the order in any meaningful way, then you’ll have to modify it so that it does. You’d have to re-import the existing images to get the proper tag order for them.

In case this is beneficial to someone we solved this by adding a timestamp column to product_tags in database.

1 Like