Fix: the same set of related products is always displayed

get_related_products_query in the WC_Product_Data_Store_CPT class is
querying the suitable products with a "limit" clause, this causes
that products down in the table are never picked for display.
This commit adds a ORDER BY RAND() to the query so that all products
have a chance to get picked.
This commit is contained in:
Nestor Soriano 2021-08-04 12:14:20 +02:00
parent be907c606d
commit 8095482f69
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
1 changed files with 2 additions and 0 deletions

View File

@ -1315,6 +1315,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
AND p.post_type = 'product'
",
'orderby' => '
ORDER BY RAND()',
'limits' => '
LIMIT ' . absint( $limit ) . '
',