diff --git a/Model/OrderImporter/Creator.php b/Model/OrderImporter/Creator.php index 3df846c..695fe7a 100644 --- a/Model/OrderImporter/Creator.php +++ b/Model/OrderImporter/Creator.php @@ -58,9 +58,6 @@ class Creator /** @var StoreManagerInterface */ private $storeManager; - /** @var Customer */ - private $customer; - /** @var ScopeConfigInterface */ private $scopeConfig; @@ -85,7 +82,6 @@ class Creator * @param CartExtensionFactory $cartExtensionFactory * @param ProductRepositoryInterface $productRepository * @param StoreManagerInterface $storeManager - * @param Customer $customer * @param ScopeConfigInterface $scopeConfig * @param QuoteManagement $quoteManagement * @param Registry $registry @@ -101,7 +97,6 @@ public function __construct( CartExtensionFactory $cartExtensionFactory, ProductRepositoryInterface $productRepository, StoreManagerInterface $storeManager, - Customer $customer, ScopeConfigInterface $scopeConfig, QuoteManagement $quoteManagement, Registry $registry @@ -116,7 +111,6 @@ public function __construct( $this->cartExtensionFactory = $cartExtensionFactory; $this->productRepository = $productRepository; $this->storeManager = $storeManager; - $this->customer = $customer; $this->scopeConfig = $scopeConfig; $this->quoteManagement = $quoteManagement; $this->registry = $registry; @@ -177,8 +171,6 @@ public function execute(CheckoutFormInterface $checkoutForm) /** * @param Quote $quote * @param CheckoutFormInterface $checkoutForm - * @throws NoSuchEntityException - * @throws LocalizedException */ private function processCustomer(Quote $quote, CheckoutFormInterface $checkoutForm) { @@ -193,12 +185,10 @@ private function processCustomer(Quote $quote, CheckoutFormInterface $checkoutFo ); } - $customer = $this->customer->get( - $checkoutForm->getBuyer(), - $store = $this->getStore(), - $checkoutForm->getInvoice()->getAddress()->getCompany()->getVatId() - ); - $quote->assignCustomer($customer); + $quote->setCustomerFirstname($checkoutForm->getBuyer()->getFirstName()); + $quote->setCustomerLastname($checkoutForm->getBuyer()->getLastName()); + $quote->setCustomerEmail($checkoutForm->getBuyer()->getEmail()); + $quote->setCustomerIsGuest(true); } /** diff --git a/Model/OrderImporter/Customer.php b/Model/OrderImporter/Customer.php deleted file mode 100644 index 4ba9b29..0000000 --- a/Model/OrderImporter/Customer.php +++ /dev/null @@ -1,58 +0,0 @@ -customerFactory = $customerFactory; - $this->customerRepository = $customerRepository; - } - - /** - * @param BuyerInterface $buyer - * @param StoreInterface $store - * @param string $vatId - * @return CustomerInterface - * @throws LocalizedException - * @throws NoSuchEntityException - */ - public function get(BuyerInterface $buyer, StoreInterface $store, $vatId) - { - $customer = $this->customerFactory->create(); - $customer->setWebsiteId($store->getWebsiteId()); - $customer->loadByEmail($buyer->getEmail()); - - if (!$customer->getId()) { - $customer - ->setFirstname($buyer->getFirstName()) - ->setLastname($buyer->getLastName()) - ->setEmail($buyer->getEmail()) - ->setTaxvat($vatId) - ->setWebsiteId($store->getWebsiteId()) - ->setStore($store) - ->save(); - } - return $this->customerRepository->getById($customer->getEntityId()); - } -}