0

so far I've experienced some complications performing this override, I had to override also PlaceOrderDefaulr, PlaceOrderFactory and PlaceOrderInferface

I've added preferences tags in ../etc/di.xml of my module to include above mentioned classes, but now the error prompted is:

Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Multishipping\Model\Checkout\Type\Multishipping::__construct() must be an instance of Magento\Checkout\Model\Session, array given, called in C:\xampp\htdocs\Magento2.2.5\app\code\Inchoo\Hello\Model\Checkout\Type\Multishipping.php on line 271 and defined in C:\xampp\htdocs\Magento2.2.5\vendor\magento\module-multishipping\Model\Checkout\Type\Multishipping.php:209 Stack trace: #0 C:\xampp\htdocs\Magento2.2.5\app\code\Inchoo\Hello\Model\Checkout\Type\Multishipping.php(271): Magento\Multishipping\Model\Checkout\Type\Multishipping->__construct(Array)

1 C:\xampp\htdocs\Magento2.2.5\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(111):

Inchoo\Hello\Model\Checkout\Type\Multishipping->__construct(Object(Magento\Checkout\Model\Session), Object(Magento\Customer\Model\Session), Object(Magento\Sales\Model\OrderFactory), Object(Magento\Customer\Model\ResourceModel\AddressRepository), Object(Magento\Framework\Event\Manager\Proxy), Object(Magento\Framework\A in C:\xampp\htdocs\Magento2.2.5\vendor\magento\module-multishipping\Model\Checkout\Type\Multishipping.php on line 209

  • Can you please add your overrided file code in question – Rutvee Sojitra Sep 27 '18 at 11:00
  • have you removed generated/code folder ? – Mukesh Prajapati Sep 27 '18 at 11:05
  • public function createOrders() { $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/multishipping.log'); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info("multishipping override file". $this->getQuote()->getId() ); die(); – user72313 Sep 27 '18 at 11:11
  • could you please post your constructor here which you have created ? – Dharmendra Jadav Sep 27 '18 at 11:13
  • I have posed the constructer code below – user72313 Sep 27 '18 at 11:18
0

Please change your cunstructor as i given below.

public function __construct(\Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Session\Generic $session, \Magento\Quote\Model\Quote\AddressFactory $addressFactory, \Magento\Quote\Model\Quote\Address\ToOrder $quoteAddressToOrder, \Magento\Quote\Model\Quote\Address\ToOrderAddress $quoteAddressToOrderAddress, \Magento\Quote\Model\Quote\Payment\ToOrderPayment $quotePaymentToOrderPayment, \Magento\Quote\Model\Quote\Item\ToOrderItem $quoteItemToOrderItem, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, \Magento\Multishipping\Helper\Data $helper, \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector, array $data = array()) {
        parent::__construct($checkoutSession, $customerSession, $orderFactory, $addressRepository, $eventManager, $scopeConfig, $session, $addressFactory, $quoteAddressToOrder, $quoteAddressToOrderAddress, $quotePaymentToOrderPayment, $quoteItemToOrderItem, $storeManager, $paymentSpecification, $helper, $orderSender, $priceCurrency, $quoteRepository, $searchCriteriaBuilder, $filterBuilder, $totalsCollector, $data);
    }

check after that.

0
 public function __construct(
    \Magento\Checkout\Model\Session $checkoutSession,
    \Magento\Customer\Model\Session $customerSession,
    \Magento\Sales\Model\OrderFactory $orderFactory,
    AddressRepositoryInterface $addressRepository,
    \Magento\Framework\Event\ManagerInterface $eventManager,
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Framework\Session\Generic $session,
    \Magento\Quote\Model\Quote\AddressFactory $addressFactory,
    \Magento\Quote\Model\Quote\Address\ToOrder $quoteAddressToOrder,
    \Magento\Quote\Model\Quote\Address\ToOrderAddress $quoteAddressToOrderAddress,
    \Magento\Quote\Model\Quote\Payment\ToOrderPayment $quotePaymentToOrderPayment,
    \Magento\Quote\Model\Quote\Item\ToOrderItem $quoteItemToOrderItem,
    \Magento\Store\Model\StoreManagerInterface $storeManager,
    \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification,
    \Magento\Multishipping\Helper\Data $helper,
    OrderSender $orderSender,
    PriceCurrencyInterface $priceCurrency,
    \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
    \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
    \Magento\Framework\Api\FilterBuilder $filterBuilder,
    \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector,
    array $data = [],
    \Magento\Quote\Api\Data\CartExtensionFactory $cartExtensionFactory = null,
    AllowedCountries $allowedCountryReader = null,
    Multishipping\PlaceOrderFactory $placeOrderFactory = null,
    LoggerInterface $logger = null,
    \Magento\Framework\Api\DataObjectHelper $dataObjectHelper = null
) {
    $this->_eventManager = $eventManager;
    $this->_scopeConfig = $scopeConfig;
    $this->_session = $session;
    $this->_addressFactory = $addressFactory;
    $this->_storeManager = $storeManager;
    $this->paymentSpecification = $paymentSpecification;
    $this->helper = $helper;
    $this->_checkoutSession = $checkoutSession;
    $this->_customerSession = $customerSession;
    $this->_orderFactory = $orderFactory;
    $this->addressRepository = $addressRepository;
    $this->orderSender = $orderSender;
    $this->priceCurrency = $priceCurrency;
    $this->quoteRepository = $quoteRepository;
    $this->searchCriteriaBuilder = $searchCriteriaBuilder;
    $this->filterBuilder = $filterBuilder;
    $this->quoteAddressToOrder = $quoteAddressToOrder;
    $this->quoteItemToOrderItem = $quoteItemToOrderItem;
    $this->quotePaymentToOrderPayment = $quotePaymentToOrderPayment;
    $this->quoteAddressToOrderAddress = $quoteAddressToOrderAddress;
    $this->totalsCollector = $totalsCollector;
    $this->cartExtensionFactory = $cartExtensionFactory ?: ObjectManager::getInstance()
        ->get(\Magento\Quote\Api\Data\CartExtensionFactory::class);
    $this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance()
        ->get(AllowedCountries::class);
    $this->placeOrderFactory = $placeOrderFactory ?: ObjectManager::getInstance()
        ->get(Multishipping\PlaceOrderFactory::class);
    $this->logger = $logger ?: ObjectManager::getInstance()
        ->get(LoggerInterface::class);
    $this->dataObjectHelper = $dataObjectHelper ?: ObjectManager::getInstance()
        ->get(\Magento\Framework\Api\DataObjectHelper::class);
   parent::__construct($data);
    $this->_init();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy