I have implemented a custom sorting of rating by creating a plugin

<type name="Magento\Catalog\Block\Product\ProductList\Toolbar">
        <plugin name="before_set_collection" type="Vendor\ModuleName\Plugin\Catalog\Product\Sorting\Custom" />

with below code in custom.php plugin file

$countColumn = new \Zend_Db_Expr("COUNT(*)"); $percentColumn = new \Zend_Db_Expr("SUM(percent)/".$countColumn );

                    'e.entity_id = rating_option_vote_aggregated.entity_pk_value',
                    array('vote_count' => 'SUM(rating_option_vote_aggregated.vote_count)','average' => $percentColumn))
            ->order('average ' . 'DESC');

Sorting and everything is working fine but the product count coming in toolbar always comes 1. Any idea why this is happening

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.