0

I have used below code in,

app/design/frontend/Custom/Theme/Magento_Catalog/templates/product/list.phtml

<?php

  $_productCollection = $block->getLoadedProductCollection();
  $_helper = $this->helper('Magento\Catalog\Helper\Output');
  $_productCollection->clear()
    ->addAttributeToFilter('best_seller',1)
     ->load();
?>

I am filtering category loaded products here, with the attribute "best_seller".

The code is working and products are filtered and showing in list page, but the count in layer navigation is not correct.

Am i used correct code? Is there any other way to override list page products.

Please anyone suggest me how this can be done? Thank you

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.