How to override core class which is already overrided by other custom module
I have module1 and module2 overriding CatalogSearch
module.
in Module1
etc/di
<preference for="Magento\CatalogSearch\Controller\Result\Index" type="Vendor\Module1\Controller\Result\Index" />
in Controller class
class Index extends \Magento\CatalogSearch\Controller\Result\Index
{
public function __construct(
Context $context,
Session $catalogSession,
StoreManagerInterface $storeManager,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
Resolver $layerResolver,
QueryFactory $queryFactory
) {
parent::__construct($context,$catalogSession,$storeManager,$resultPageFactory,$queryFactory,$layerResolver);
$this->resultPageFactory = $resultPageFactory;
$this->layerResolver = $layerResolver;
$this->_queryFactory = $queryFactory;
$this->_storeManager = $storeManager;
}
In Module2
etc/di
<preference for="Vendor\Module1\Controller\Result\Index" type="Vendor\Module2\Controller\Result\Index" />
In Controller class
class Index extends \Vendor\Module1\Controller\Result\Index
{
public function __construct(
Context $context,
Session $catalogSession,
StoreManagerInterface $storeManager,
Http $request,
LayoutInterface $layout,
ScopeConfigInterface $scopeConfig,
Resolver $layerResolver,
\Magento\Catalog\Model\CategoryFactory $catalogCategoryFactory,
\Magento\Framework\Registry $registry,
\Vendor\Module1\Model\Client\Connector $tglssearchClientConnector,
QueryFactory $queryFactory,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
parent::__construct($context,$catalogSession,$storeManager,$queryFactory,$layerResolver);
$this->_storeManager = $storeManager;
$this->catalogSession = $catalogSession;
$this->storeManager = $storeManager;
$this->request = $request;
$this->layout = $layout;
$this->scopeConfig = $scopeConfig;
$this->catalogCategoryFactory = $catalogCategoryFactory;
$this->registry = $registry;
$this->tglssearchClientConnector = $tglssearchClientConnector;
$this->layerResolver = $layerResolver;
$this->_queryFactory = $queryFactory;
$this->resultPageFactory = $resultPageFactory;
/* parent::__construct(
$context
); */
}
I get below error,
Argument 4 passed to Vendor\Module1\Controller\Result\Index::__construct() must be an instance of Magento\Framework\View\Result\PageFactory, instance of Magento\Search\Model\QueryFactory given, called in C:\xampp\htdocs\magento2x_5test\app\code\Vendor\Module2\Controller\Result\Index.php on line 36 and defined in C:\xampp\htdocs\magento2x_5test\app\code\Vendor\Module1\Controller\Result\Index.php on line 22