I have the following class in Magento 2:

namespace Vendor\MyModule\Block;

class ProductTab extends \Magento\Catalog\Block\Adminhtml\Category\Tab\Product
     * @var \Magento\Framework\App\Config\ScopeConfigInterface
    protected $_scopeConfig;

     * @param \Magento\Backend\Block\Template\Context $context
     * @param \Magento\Backend\Helper\Data $backendHelper
     * @param \Magento\Catalog\Model\ProductFactory $productFactory
     * @param \Magento\Framework\Registry $coreRegistry
     * @param array $data
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Backend\Helper\Data $backendHelper,
        \Magento\Catalog\Model\ProductFactory $productFactory,
        \Magento\Framework\Registry $coreRegistry,
        array $data = [],
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    ) {
        $this->_productFactory = $productFactory;
        $this->_coreRegistry = $coreRegistry;
        $this->_scopeConfig = $scopeConfig;
        parent::__construct($context, $backendHelper, $coreRegistry, $data);

After running rm -rf var/di && bin/magento setup:di:compile I get the following error:

Errors during compilation: Vendor\MyModule\Block\ProductTab Incompatible argument type: Required type: \Magento\Catalog\Model\ProductFactory. Actual type: \Magento\Framework\Registry; File: /var/www/magento/app/code/Vendor/MyModule/Block/ProductTab.php Total Errors Count: 1

What have I done wrong? I don't get it... I just copied the construct-function of the parent and added a 6th argument to it (the scope config).

1 Answer 1


See at this line of your constructor:

parent::__construct($context, $backendHelper, $coreRegistry, $data);

You have missed $productFactory at 3rd position.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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