Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Secondary Sorting Changed In V4? Rate Topic   - - - - -

 
  • Karstedt
  • Member
  • Members
  • Join Date: 09-Dec 15
  • 41 posts

Posted 24 December 2015 - 05:54 AM #1

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?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21791 posts

Posted 24 December 2015 - 09:09 AM #2

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12044 posts

Posted 24 December 2015 - 09:00 PM #3

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Karstedt
  • Member
  • Members
  • Join Date: 09-Dec 15
  • 41 posts

Posted 25 December 2015 - 11:41 AM #4

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.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21791 posts

Posted 25 December 2015 - 03:30 PM #5

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!


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)