0
Fatal error: Uncaught TypeError: Argument 1 passed to FDB\FreeSamples\Helper\SampleCategories::__construct() must be an instance of FDB\FreeSamples\Model\Checkout\Type\Onepage, instance of Magento\Checkout\Model\Type\Onepage\Interceptor given,

Model

namespace FDB\FreeSamples\Model\Checkout\Type;

class Onepage extends \Magento\Checkout\Model\Type\Onepage
{
}

I am attempting to the load class in a helper:

public function __construct(
        \FDB\FreeSamples\Model\Checkout\Type\Onepage $onePage
    ) {
        $this->_onePage = $onePage;
        parent::__construct($context);
    }
0

You must inject \Magento\Framework\App\Helper\Context $context at your helper class.

namespace FDB\FreeSamples\Helper;
class SampleCategories{
protected $_onePage;  
  ....
public function __construct(
  \Magento\Framework\App\Helper\Context $context,
        \FDB\FreeSamples\Model\Checkout\Type\Onepage $onePage
    ) {
        $this->_onePage = $onePage;
        parent::__construct($context);
    }
  ....
}

Also __construct() FDB\FreeSamples\Model\Checkout\Type\Onepage does not define properly.


<?php
namespace FDB\FreeSamples\Model\Checkout\Type;

use Magento\Customer\Api\AccountManagementInterface;
use Magento\Customer\Api\AddressMetadataInterface as AddressMetadata;
use Magento\Customer\Api\AddressRepositoryInterface;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterfaceFactory as CustomerDataFactory;
use Magento\Customer\Api\Data\GroupInterface;
use Magento\Customer\Model\Metadata\Form;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;

class Onepage extends \Magento\Checkout\Model\Type\Onepage{


    public function __construct(
        \Magento\Framework\Event\ManagerInterface $eventManager,
        \Magento\Checkout\Helper\Data $helper,
        \Magento\Customer\Model\Url $customerUrl,
        \Psr\Log\LoggerInterface $logger,
        \Magento\Checkout\Model\Session $checkoutSession,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\App\RequestInterface $request,
        \Magento\Customer\Model\AddressFactory $customrAddrFactory,
        \Magento\Customer\Model\FormFactory $customerFormFactory,
        \Magento\Customer\Model\CustomerFactory $customerFactory,
        \Magento\Sales\Model\OrderFactory $orderFactory,
        \Magento\Framework\DataObject\Copy $objectCopyService,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Customer\Model\Metadata\FormFactory $formFactory,
        CustomerDataFactory $customerDataFactory,
        \Magento\Framework\Math\Random $mathRandom,
        \Magento\Framework\Encryption\EncryptorInterface $encryptor,
        AddressRepositoryInterface $addressRepository,
        AccountManagementInterface $accountManagement,
        OrderSender $orderSender,
        CustomerRepositoryInterface $customerRepository,
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
        \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
        \Magento\Quote\Api\CartManagementInterface $quoteManagement,
        \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
        \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
    ) {
        parent::__construct(
            $eventManager,
            $helper,
            $customerUrl,
            $logger,
            $checkoutSession,
            $customerSession,
            $storeManager,
            $request,
            $customrAddrFactory,
            $customerFormFactory,
            $customerFactory,
            $orderFactory,
            $messageManager,
            $formFactory,
            $orderSender,
            $customerDataFactory,
            $mathRandom,
            $encryptor,
            $addressRepository,
            $quoteRepository,
            $extensibleDataObjectConverter,
            $quoteManagement,
            $dataObjectHelper,
            $totalsCollector
        );
    }

}
  • still getting the same error. – LRV Mar 30 '17 at 19:11
  • what type of error.. you have getting – Amit Bera Mar 30 '17 at 20:37
  • Fatal error: Uncaught TypeError: Argument 8 passed to FDB\FreeSamples\Helper\SampleCategories::__construct() must be an instance of FDB\FreeSamples\Model\Checkout\Type\Onepage, instance of Magento\Checkout\Model\Type\Onepage\Interceptor given, – LRV Mar 30 '17 at 21:13
0

if you want to extend Magento\Checkout\Model\Type\Onepage class,

Your __construct() method look like below in your FDB\FreeSamples\Model\Checkout\Type\Onepage,

<?php
 public function __construct(
        \Magento\Framework\Event\ManagerInterface $eventManager,
        \Magento\Checkout\Helper\Data $helper,
        \Magento\Customer\Model\Url $customerUrl,
        \Psr\Log\LoggerInterface $logger,
        \Magento\Checkout\Model\Session $checkoutSession,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Framework\App\RequestInterface $request,
        \Magento\Customer\Model\AddressFactory $customrAddrFactory,
        \Magento\Customer\Model\FormFactory $customerFormFactory,
        \Magento\Customer\Model\CustomerFactory $customerFactory,
        \Magento\Sales\Model\OrderFactory $orderFactory,
        \Magento\Framework\DataObject\Copy $objectCopyService,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Customer\Model\Metadata\FormFactory $formFactory,
        \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerDataFactory,
        \Magento\Framework\Math\Random $mathRandom,
        \Magento\Framework\Encryption\EncryptorInterface $encryptor,
        \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
        \Magento\Customer\Api\AccountManagementInterface $accountManagement,
        \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender,
        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
        \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter,
        \Magento\Quote\Api\CartManagementInterface $quoteManagement,
        \Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
        \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector,
        \FDB\FreeSamples\Model\Checkout\Type\Onepage $onePage
    ) {
        $this->_onePage = $onePage;
        parent::__construct(
        $eventManager,
        $customerUrl,
        $helper,
        $checkoutSession,
        $customerSession,
        $logger,
        $storeManager,
        $request,
        $customrAddrFactory,
        $customerFormFactory,
        $customerFactory,
        $orderFactory,
        $objectCopyService,
        $messageManager,
        $formFactory,
        $customerDataFactory,
        $mathRandom,
        $encryptor,
        $addressRepository,
        $accountManagement,
        $orderSender,
        $customerRepository,
        $quoteRepository,
        $extensibleDataObjectConverter,
        $quoteManagement,
        $dataObjectHelper,
        $totalsCollector
        );
    }

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.