3

I get below error when we check custom grid collection in admin. How to solve this

Recoverable Error: Argument 6 passed to Namespace\Module\Model\ResourceModel\Notification\Collection::__construct() must be an instance of Magento\Framework\Stdlib\DateTime\DateTime, null given, called in /var/www/html/magento24/app/code/Namespace/Module/Model/ResourceModel/Notification/Grid/Collection.php on line 54 and defined in /var/www/html/magento24/app/code/Namespace/Module/Model/ResourceModel/Notification/Collection.php on line 62

3

If you extend from some core model, make sure to pass all required arguments to parent::__construct(), which should be called from __construct() in your class. Your class construct must accept the same list of arguments as parent, plus you can add new dependencies as follows:

Parent construct:

public function __construct(
    \Parent\Required\Dependency $parentRequiredDependency,
    \Parent\Optional\Dependency $parentOptionalDependency = null
) {
    /** Parent code goes here */
}

Child construct:

public function __construct(
    \Parent\Required\Dependency $parentRequiredDependency,
    \New\Required\Dependency $newRequiredDependency,
    \Parent\Optional\Dependency $parentOptionalDependency = null,
    \New\Optional\Dependency $newOptionalDependency = null
) {
    parent::__construct($parentRequiredDependency, $parentOptionalDependency);
    /** Custom code goes here */
}
  • this is veru useful instruction for extend core class. – Rakesh Jesadiya Dec 3 '15 at 10:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.