0

I would like to show the prdoucts based on the above 3 star rating using custom collection method.

public function getProductCollection()
    {

        $collection = $this->_productCollectionFactory->create();        
        $collection->addAttributeToSelect('*')
        ->joinField('rating_score',
        'review_entity_summary',
        'rating_summary',
        'entity_pk_value=entity_id',
        array('entity_type'=>1, 'store_id'=> $this->storeManager->getStore()->getId(), 'rating_summary'=> 100),
        'right'
        );
         $collection->addAttributeToFilter('status', array('eq' => 1) );

        $collection->setPageSize(10); // fetching only 3 products        
        return $collection;
    }
1

Replace rating summary value 100 to 60

public function getProductCollection() {

    $collection = $this->_productCollectionFactory->create();        
    $collection->addAttributeToSelect('*')
    ->joinField('rating_score',
    'review_entity_summary',
    'rating_summary',
    'entity_pk_value=entity_id',
    array('entity_type'=>1, 'store_id'=> $this->storeManager->getStore()->getId(), 'rating_summary'=> 60),
    'right'
    );
     $collection->addAttributeToFilter('status', array('eq' => 1) );

    $collection->setPageSize(10); // fetching only 3 products        
    return $collection;
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.