Magento 2 error : Incompatible argument type: Required type: \Magento\Framework\Registry. Actual type: array; File:

magento.stackexchange https://magento.stackexchange.com/questions/332435

Question

Code

use Magento\CustomerBalance\Helper\Data;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;

/**
 * Refund to customer balance functionality block
 *
 * @api
 * @since 100.0.2
 */
class Controls extends Template
{
    /**
     * Core registry
     *
     * @var Registry
     */
    protected $_coreRegistry = null;

    /**
     * @param Context $context
     * @param Registry $registry
     * @param array $data
     * @param Data|null $customerBalanceHelper
     */
    public function __construct(
        Context $context,
        Registry $registry,
        array $data = [],
        Data $customerBalanceHelper = null
    ) {
        $data['customerBalanceHelper'] =  $customerBalanceHelper ?? ObjectManager::getInstance()->get(Data::class);
        $this->_coreRegistry = $registry;
        parent::__construct($context, $data);
    }
Was it helpful?

Solution

Try to replace below line:

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

With this one:

parent::__construct($context, $registry, $data);
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top