Secondary Sorting Changed In V4?

There appears to be a secondary sort parameter in v4 that was not there in v2. I sort by position:

v2.x: sorts products by pos, then by product_id

v4.x: sorts by pos, then by something unknown... and the order changes depending on how many products I show in the grid, eg if I show 48 products instead of 12 they will be in a different order.

What is the secondary sorting in v4? Why does the order change? Any idea how to get it to work like 2.x and go back to using the product_id?

I do not see any secondary sorting in the code. Try to open the app/functions/fn.catalog.php file and replace:

'position' => 'products_categories.position',

with

'position' => 'products_categories.position, products.product_id',

(!) Not tested

The only reason you're seeing sort by product_id is because that's the database table order. If the ORDER BY resolves to duplicate items and there is no additional ORDER BY declaration then it will simply use the order it finds things in the db.

The only reason you're seeing sort by product_id is because that's the database table order. If the ORDER BY resolves to duplicate items and there is no additional ORDER BY declaration then it will simply use the order it finds things in the db.

I know, but the kicker is that v4 does not appear to use the table order as a fallback. So the person who sorted things gave lots of things the same pos and they sorted how he wanted because of the order he uploaded them. Now obviously I have x items at pos y getting some kind of 'random' (it's not random but I can't figure our what it's keying on) sort, that changes based on how many products I display in the grid.

I do not see any secondary sorting in the code. Try to open the app/functions/fn.catalog.php file and replace:

'position' => 'products_categories.position',

with

'position' => 'products_categories.position, products.product_id',

(!) Not tested

Good idea, works great and much simpler than poking around appending something to the $sortings variable (which is what I was looking at). Cheers.

Good idea, works great and much simpler than poking around appending something to the $sortings variable (which is what I was looking at). Cheers.

You are welcome!