From 7fc9056585939fa7dba41964b0c332999fa7fafc Mon Sep 17 00:00:00 2001 From: Cid Lopes Date: Wed, 27 Mar 2024 14:37:55 +0200 Subject: [PATCH] Remove buyer data from order data --- Model/Order/Builder.php | 12 +--- Model/Order/Buyer/Builder.php | 107 ---------------------------------- Observer/Order/Save.php | 2 - 3 files changed, 2 insertions(+), 119 deletions(-) delete mode 100644 Model/Order/Buyer/Builder.php diff --git a/Model/Order/Builder.php b/Model/Order/Builder.php index 2e233c94a..13391f09f 100644 --- a/Model/Order/Builder.php +++ b/Model/Order/Builder.php @@ -52,7 +52,6 @@ use Nosto\Model\Order\OrderStatus; use Nosto\NostoException; use Nosto\Tagging\Logger\Logger as NostoLogger; -use Nosto\Tagging\Model\Order\Buyer\Builder as NostoBuyerBuilder; use Nosto\Tagging\Model\Order\Item\Builder as NostoOrderItemBuilder; class Builder @@ -63,27 +62,23 @@ class Builder private SalesRuleFactory $salesRuleFactory; private NostoOrderItemBuilder $nostoOrderItemBuilder; private ManagerInterface $eventManager; - private NostoBuyerBuilder $buyerBuilder; /** * @param NostoLogger $logger * @param SalesRuleFactory $salesRuleFactory * @param NostoOrderItemBuilder $nostoOrderItemBuilder * @param ManagerInterface $eventManager - * @param NostoBuyerBuilder $buyerBuilder */ public function __construct( NostoLogger $logger, SalesRuleFactory $salesRuleFactory, NostoOrderItemBuilder $nostoOrderItemBuilder, - ManagerInterface $eventManager, - NostoBuyerBuilder $buyerBuilder + ManagerInterface $eventManager ) { $this->logger = $logger; $this->salesRuleFactory = $salesRuleFactory; $this->nostoOrderItemBuilder = $nostoOrderItemBuilder; $this->eventManager = $eventManager; - $this->buyerBuilder = $buyerBuilder; } /** @@ -120,10 +115,7 @@ public function build(Order $order) } $nostoOrder->setOrderStatus($nostoStatus); } - $nostoBuyer = $this->buyerBuilder->fromOrder($order); - if ($nostoBuyer instanceof Buyer) { - $nostoOrder->setCustomer($nostoBuyer); - } + $nostoOrder->setCustomer(new Buyer()); // Add each ordered item as a line item /** @var Item $item */ diff --git a/Model/Order/Buyer/Builder.php b/Model/Order/Buyer/Builder.php deleted file mode 100644 index 071508ea2..000000000 --- a/Model/Order/Buyer/Builder.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright 2020 Nosto Solutions Ltd - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause - * - */ - -namespace Nosto\Tagging\Model\Order\Buyer; - -use Magento\Sales\Api\Data\OrderAddressInterface; -use Magento\Sales\Model\Order; -use Nosto\Model\Order\Buyer; -use Nosto\Tagging\Model\Person\Builder as PersonBuilder; - -/** - * Builder class for buyer - */ -class Builder extends PersonBuilder -{ - /** - * @inheritDoc - * @return Buyer - */ - public function buildObject( // @codingStandardsIgnoreLine - string $firstName, - string $lastName, - string $email, - string $phone = null, - string $postCode = null, - string $country = null, - string $customerGroup = null, - string $dateOfBirth = null, - string $gender = null, - string $customerReference = null - ) { - $buyer = new Buyer(); - $buyer->setFirstName($firstName); - $buyer->setLastName($lastName); - $buyer->setEmail($email); - $buyer->setPhone($phone); - $buyer->setPostCode($postCode); - $buyer->setCountry($country); - - return $buyer; - } - - /** - * Builds buyer from the order - * - * @param Order $order - * @return \Nosto\Model\AbstractPerson|null - * @suppress PhanTypeMismatchArgument - * @noinspection PhpFullyQualifiedNameUsageInspection - */ - public function fromOrder(Order $order) - { - $address = $order->getBillingAddress(); - $telephone = null; - $postcode = null; - $countryId = null; - if ($address instanceof OrderAddressInterface) { - $telephone = $address->getTelephone() ? (string)$address->getTelephone() : null; - $postcode = $address->getPostcode() ? (string)$address->getPostcode() : null; - $countryId = $address->getCountryId() ? (string)$address->getCountryId() : null; - } - $customerFirstname = $order->getCustomerFirstname() ? (string)$order->getCustomerFirstname() : ''; - $customerLastname = $order->getCustomerLastname() ? (string)$order->getCustomerLastname() : ''; - $customerEmail = $order->getCustomerEmail() ? (string)$order->getCustomerEmail() : ''; - return $this->build( - $customerFirstname, - $customerLastname, - $customerEmail, - $telephone, - $postcode, - $countryId - ); - } -} diff --git a/Observer/Order/Save.php b/Observer/Order/Save.php index 4b03e6e13..37589c72f 100644 --- a/Observer/Order/Save.php +++ b/Observer/Order/Save.php @@ -46,7 +46,6 @@ use Magento\Framework\Module\Manager as ModuleManager; use Magento\Sales\Model\Order; use Magento\Store\Model\Store; -use Nosto\Model\Order\Buyer; use Nosto\Model\Order\Order as NostoOrder; use Nosto\Operation\Order\OrderCreate as NostoOrderCreate; use Nosto\Operation\Order\OrderStatus as NostoOrderUpdate; @@ -256,7 +255,6 @@ private function sendNewOrder(Order $order, AccountInterface $nostoAccount, Stor $nostoCustomerIdentifier = NostoOrderCreate::IDENTIFIER_BY_REF; } $nostoOrder = $this->nostoOrderBuilder->build($order); - $nostoOrder->setCustomer(new Buyer()); // Remove customer data from order API calls if ($nostoCustomerId !== null) { try { $orderService = new NostoOrderCreate(