Sort Order Of Rating Block On Homepage?

I have a block on the homepage and the filling is set to "Rating"

Works but problem is that it lists products by rating then alphabetically and completely ignores those products with hundreds of reviews, but instead lists all the 5 star reviews 1st regardless of 1 or 2 reviews only.

I want to change it to sort by # of reviews instead of alphabetical

I found this bit of code that does it but not the code that is used for the block filling "Rating"

/app/addons/product_reviews?func.php

    $params['sort_by'] = 'rating';
    $params['sort_order'] = 'desc';
    $sortings['rating'] = ['average_rating', 'product_reviews_count'];

In a nutshell, I want a product with 4.6 stars and 100+ ratings to appear in the block before a 5 star with just 1 review

Does anyone know where the function is located that produces the block filling type "Rating"?

Do you use old or new module for product reviews?

Do you use old or new module for product reviews?

was using the new version but have since installed CP Power Reviews so the ratings are being added into the cscart_discussion_ group of tables as opposed to the cscart_product_reviews tables

So you should alter the fn_discussion_get_products function

Add extra field to calculate posts amount and add it to sorting

So you should alter the fn_discussion_get_products function

Add extra field to calculate posts amount and add it to sorting

thanks for the info, the function in question is:

function fn_discussion_get_products(&$params, &$fields, &$sortings, &$condition, &$join, &$sorting, &$group_by, &$lang_code, &$having)
{
    if (
        !empty($params['rating'])
        && Registry::get('addons.product_reviews.status') !== ObjectStatuses::ACTIVE
    ) {
        $fields[] = 'AVG(?:discussion_rating.rating_value) AS average_rating';
        $fields[] = '?:discussion.type AS discussion_type';
        $fields[] = '?:discussion.thread_id AS discussion_thread_id';
        $join .= db_quote(" LEFT JOIN ?:discussion ON ?:discussion.object_id = products.product_id AND ?:discussion.object_type = 'P'");
    if (fn_allowed_for('ULTIMATE') && Registry::ifGet('addons.discussion.product_share_discussion', 'N') == 'N' && Registry::get('runtime.company_id')) {
        $join .= " AND ?:discussion.company_id = " . Registry::get('runtime.company_id');
    }

    $join .= db_quote(" LEFT JOIN ?:discussion_posts ON ?:discussion_posts.thread_id = ?:discussion.thread_id AND ?:discussion_posts.status = 'A'");
    if (!empty($params['start_rating_period'])) {
        $join .= db_quote(' AND ?:discussion_posts.timestamp > ?i', $params['start_rating_period']);
    }

    $join .= db_quote(" LEFT JOIN ?:discussion_rating ON ?:discussion.thread_id = ?:discussion_rating.thread_id AND ?:discussion_rating.post_id = ?:discussion_posts.post_id AND ?:discussion_rating.rating_value != 0");

    $having[] = db_quote("average_rating > 0");
    $params['sort_by'] = 'rating';
    $params['sort_order'] = 'desc';
    $sortings['rating'] = 'average_rating';
}

return true;

}

what I would like to do is add a limit to the selected ratings to only those with 50 or more posts.

but honestly am not sure how to add that limit correctly and only apply it to the block in question

any additional help is appreciated

Try to add something like

$fields[] = 'COUNT(?:discussion_posts.post_id) as posts_count';
$having[] = db_quote("posts_count > 50");

(!) Not tested

Try to add something like

$fields[] = 'COUNT(?:discussion_posts.post_id) as posts_count';
$having[] = db_quote("posts_count > 50");

(!) Not tested

thanks, that worked but for some reason still showing some with less than the limit set. at least I got rid of the 1 review listings at the start of the block