(a) In the product screen the query looks like this (some places with IN other places with =):
SELECT *
FROM saj_hikashop_file
WHERE file_ref_id IN (142)
AND file_type = 'product'
Could it be changed to:
SELECT *
FROM saj_hikashop_file
WHERE file_ref_id IN (142)
AND file_type = 'product'
ORDER BY file_id ASC
(b) In the category product listing screen the query looks like this:
SELECT a.*,b.*
FROM saj_hikashop_category AS a
LEFT JOIN saj_hikashop_file AS b
ON a.category_id=b.file_ref_id
AND b.file_type='category'
WHERE a.category_id = 1
LIMIT 1
Could it be changed to:
SELECT a.*,b.*
FROM saj_hikashop_category AS a
LEFT JOIN saj_hikashop_file AS b
ON a.category_id=b.file_ref_id
AND b.file_type='category'
WHERE a.category_id = 1
ORDER BY b.file_id ASC
LIMIT 1
For (a) I could solve this in the product template by running my own PHP sort function over '$this->element->images'.
For (b) looks like it would be more work in the category template as I would have to write my own query.
Without the ORDER BY is relying on the database engine implementation as to which is the first and may change with different versions / engines.