I tried the code of @Nitesh here Add search by category by Nitesh
and I got this error:
Notice: Undefined property:
Magento\CatalogSearch\Model\Advanced::$_objectManager in
/opt/lampp/htdocs/mwh-das-original/vendor/magento/module-catalog-search/Model/Advanced.php
on line 269
Best Answer
There is error in the @Nitesh code, because the
Magento\CatalogSearch\Model\Advanced
class has no attribute_objectManager
. To make it work you should add this attribute in a class which rewritesMagento\CatalogSearch\Model\Advanced
, I think you have it because @Nitesh says:So, just declare the
__construct
method and add theObjectManager
instance and attribute, like:PS: update the class which rewrites
Magento\CatalogSearch\Model\Advanced
class using this code, but do not overwrite it completely.