I am trying to override the controller of an extension in Magento2.
My di.xml file is:-
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Mycustom\Custom\Controller\Adminhtml\Controllerfolder\Fileaction" type="ActualModule\Custom\Controller\Adminhtml\Controllerfolder\Fileaction"/>
</config>
I have cloned the controller file with updated namespaces, and extend the controller to module's file like:-
<?php
namespace Mycustom\Custom\Controller\Adminhtml\Controllerfolder;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
use ActualModule\Custom\Model\OrderFactory;
class Fileaction extends \ActualModule\Custom\Controller\Adminhtml\Controllerfolder\Fileaction
{
/**
* @var OrderFactory
*/
protected $_modelOrderFactory;
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory,
OrderFactory $modelOrderFactory)
{
parent::__construct($context, $filter);
$this->collectionFactory = $collectionFactory;
$this->_modelOrderFactory = $modelOrderFactory;
}
protected function massAction(AbstractCollection $collection)
{
die('here');
}
It should be functional but the issue I get on php bin/magento s:d:c
is as follow:-
Errors during compilation:
ActualModule\Custom\Controller\Adminhtml\Controllerfolder\Fileaction
Missed required argument collectionFactory in parent::__construc
t call. File: C:/wamp64/www/magento/app/code/Mycustom\Custom\Controller\Adminhtml\Controllerfolder/Fileaction.php
Total Errors Count: 1
Errors during compilation:
I feel like I missed something but not able to catch what.
Just to add var/generation, di etc.. clearing has been done, cache flushed.