BUG: Wrong order in latest products widget.
-
Hi guys, not sure if this is an intended behaviour, but we didn’t expect widget Latest Products to sort the products the way they are done with the latest version at the time of posting this thread. This might be the same for other people.
After diving in the plugin’s code, I figured that ordering is done by ID. This is understandable, but might not be accurate all the time, as compared to ordering by post_date.
I would like to know if this is intended, and if not, will it be fixed in the next version? Thanks.
A quick amendment to order products more accurately by publish date of the product can be found below:
file: wp-product-review/includes/admin/models/class-wppr-query-model.php
from line 144 replace the $query string to:$query = " SELECT * FROM ( SELECT <code>post_id</code> AS 'ID', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'cwp_meta_box_check', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'cwp_meta_box_check', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'cwp_rev_product_name', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'cwp_rev_product_name', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'cwp_image_link', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'cwp_image_link', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'cwp_rev_product_image', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'cwp_rev_product_image', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'cwp_rev_price', FORMAT( <code>meta_value</code>, 2 ), '' ) SEPARATOR '' ) AS 'cwp_rev_price', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'wppr_rating', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'wppr_rating', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'wppr_pros', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'wppr_pros', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'wppr_cons', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'wppr_cons', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'wppr_options', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'wppr_options', GROUP_CONCAT( DISTINCT IF( <code>meta_key</code> = 'wppr_links', <code>meta_value</code>, '' ) SEPARATOR '' ) AS 'wppr_links', post_date FROM {$this->db->postmeta} INNER JOIN {$this->db->posts} ON {$this->db->postmeta}.post_id = {$this->db->posts}.ID {$sub_query_posts} GROUP BY <code>ID</code> ) <code>pivoted_meta</code> WHERE <code>cwp_meta_box_check</code> = 'Yes' {$conditions} ORDER BY {$order_by} <code>cwp_rev_product_name</code> ASC LIMIT {$limit} ";Within same file, find get_order_by method and change the date $order_by to this:
$order_by .= "post_date {$order['date']}, ";
The topic ‘BUG: Wrong order in latest products widget.’ is closed to new replies.