0
 protected function _initSelect()
{
    parent::_initSelect();
    $agent_id = $this->request->getParam('agent_id');

}

Try to get "agent_id" from url but getting this eror

Type Error occurred when creating object: Magedelight\DeliveryAgent\Model\ResourceModel\DeliveryAgentShipment\Grid\Collection\Interceptor, Argument 1 passed to Magedelight\DeliveryAgent\Model\ResourceModel\DeliveryAgentShipment\Grid\Collection\Interceptor::__construct() must implement interface Magento\Framework\App\RequestInterface, instance of Magento\Framework\Data\Collection\EntityFactory given, called in /var/www/html/CE/241/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121

construct signature

public function __construct(
  \Magento\Framework\App\Request\Http $request,
    EntityFactory $entityFactory,
    Logger $logger,
    FetchStrategy $fetchStrategy,
    EventManager $eventManager,
    $mainTable = 'magedelight_delivery_agent_shipment',
    $resourceModel = "Magedelight\DeliveryAgent\Model\ResourceModel\DeliveryAgentShipment",
    $identifierName = null,
    $connectionName = null
) {
    $this->request = $request;
    parent::__construct(
        $entityFactory,
        $logger,
        $fetchStrategy,
        $eventManager,
        $mainTable,
        $resourceModel,
        $identifierName,
        $connectionName
    );
}
0

you can getby injecting Http class to __construct

protected $request;

public function __construct(
    ...
     \Magento\Framework\App\Request\Http $request,
    ...
) {
    $this->request = $request;
}

public function getRequestData()
{
    return $this->request->getParam('agent_id');
}

3
  • I tried this but getting same error. this one Type Error occurred when creating object: Model\ResourceModel\DeliveryAgentShipment\Grid\Collection\Interceptor, Argument 1 passed to Model\ResourceModel\DeliveryAgentShipment\Grid\Collection\Interceptor::__construct() must implement interface Magento\Framework\App\RequestInterface, instance of Magento\Framework\Data\Collection\EntityFactory given, called in /var/www/html/CE/241/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121 – vivek Apr 6 at 11:57
  • can you please show me your constructor signature? – Niraj Apr 6 at 12:02
  • Edit above please check – vivek Apr 6 at 12:44

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.