3

How to override my custom catalogsearch block? and what is the equivalent class for below in magento2? and how to override in di?

   <catalogsearch>
      <rewrite>
        <layer>Vendor_Module_Block_CatalogSearch_Layer</layer>
      </rewrite>
    </catalogsearch>

My custom catalosearch override is as:

 <preference for="Magento\LayeredNavigation\Block\Navigation" type="Vendor\Module\Block\CatalogSearch\Layer" />

is that correct class? cause in magento1x , we do by

class Vendor_Module_Block_CatalogSearch_Layer extends Mage_CatalogSearch_Block_Layer {}

But in magento2, thr is no such Layer in CatalogSearch. Please suggest

1

You can use

Magento\LayeredNavigation\Block\Navigation

  1. In this class the layer object getLayer returns \Magento\Catalog\Model\Layer.

  2. Also you can find some important layered navigation functions at Magento\Catalog\Model\LayerandLayer.php.

  3. You may not find ( Magento 1.X )exact or entire class in Magento 2 but we can identify the flow to customize or extend the functionality by using modules.

Assume you know how to extend or override core classes in Magento 2 ( Standard way is by creating custom module )

Hope this helps.

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.