2

ERROR - Incompatible argument type: Required type: \Magento\Directory\Model\CountryFactory. Actual type: array; File: Magento2/app/code/Vendor/Module/Model/Api/Nvp.php

Original file - /Magento2/vendor/magento/module-paypal/Model/Api/Nvp.php

public function __construct(
        \Magento\Customer\Helper\Address $customerAddress,
        \Psr\Log\LoggerInterface $logger,
        Logger $customLogger,
        \Magento\Framework\Locale\ResolverInterface $localeResolver,
        \Magento\Directory\Model\RegionFactory $regionFactory,
        \Magento\Directory\Model\CountryFactory $countryFactory,
        \Magento\Paypal\Model\Api\ProcessableExceptionFactory $processableExceptionFactory,
        \Magento\Framework\Exception\LocalizedExceptionFactory $frameworkExceptionFactory,
        \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory,
        array $data = []
    ) {
        parent::__construct($customerAddress, $logger, $customLogger, $localeResolver, $regionFactory, $data);
        $this->_countryFactory = $countryFactory;
        $this->_processableExceptionFactory = $processableExceptionFactory;
        $this->_frameworkExceptionFactory = $frameworkExceptionFactory;
        $this->_curlFactory = $curlFactory;
    }

Override file - Magento2/app/code/Vendor/Module/Model/Api/Nvp.php

public function __construct(
        \Magento\Customer\Helper\Address $customerAddress,
        \Psr\Log\LoggerInterface $logger,
        Logger $customLogger,
        \Magento\Framework\Locale\ResolverInterface $localeResolver,
        \Magento\Directory\Model\RegionFactory $regionFactory,
        \Magento\Directory\Model\CountryFactory $countryFactory,
        \Magento\Paypal\Model\Api\ProcessableExceptionFactory $processableExceptionFactory,
        \Magento\Framework\Exception\LocalizedExceptionFactory $frameworkExceptionFactory,
        \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory,
        array $data = []
    ) {
        parent::__construct($customerAddress, $logger, $customLogger, $localeResolver, $regionFactory, $data);
        $this->_countryFactory              = $countryFactory;
        $this->_processableExceptionFactory = $processableExceptionFactory;
        $this->_frameworkExceptionFactory   = $frameworkExceptionFactory;
        $this->_curlFactory                 = $curlFactory;
    }
12
  • Any thoughts on this, how to fix this ? – devhs May 3 at 11:20
  • What is the difference between original and overridden file ? and also that error may you please share the full error ? – Vibhore Jain May 3 at 11:23
  • Incompatible argument type: Required type: \Magento\Directory\Model\CountryFactory. Actual type: array; File: Overriden file – devhs May 3 at 11:24
  • I have run di:compile & that error appeared, seems like issue with constructor – devhs May 3 at 11:26
  • I have updated question – devhs May 3 at 11:26
2

Try this solution it can help you in solving this problem
https://community.magento.com/t5/Magento-2-x-Programming/Incompatible-Argument-Type-Required-Collection-Factory/m-p/128809#M7527
I hope it will help you.

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.