6

I have successfully extend the _getProductCollection function at \Magento\Catalog\Block\Product\ListProduct to my custom module block, the problem is I need to add text input to layered navigation so I can get the requested data in my block and do some custom filtering product collection roughly like this:

    protected function _getProductCollection()
    {
        $productCollection = parent::_getProductCollection(); 
        if(isset($_GET['custom_input'])){
          if(!empty($_GET['custom_input']){
            $customInput = $_GET['custom_input'];
            $productCollection = $this->myModuleHelper->filterProduct(customInput, productCollection);
          }
        }
        $this->_productCollection = $productCollection;
        $this->_productCollection->getSize();
        return $proCollection;
    }

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.