From ea70c0ba65fd76c037c33ed77e1e1a40abbdb45a Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Wed, 18 Mar 2020 15:52:23 +0100 Subject: [PATCH 01/13] #26682 Disallow setting extension attributes as data array --- app/code/Magento/Quote/Model/ShippingMethodManagement.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index 73a2a43b2581f..202eeb765216b 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -309,7 +309,13 @@ private function getShippingMethods(Quote $quote, $address) { $output = []; $shippingAddress = $quote->getShippingAddress(); - $shippingAddress->addData($this->extractAddressData($address)); + + $extractedAddressData = $this->extractAddressData($address); + if (array_key_exists('extension_attributes', $extractedAddressData)) { + unset($extractedAddressData['extension_attributes']); + } + $shippingAddress->addData($extractedAddressData); + $shippingAddress->setCollectShippingRates(true); $this->totalsCollector->collectAddressTotals($quote, $shippingAddress); From dcb59d31677bee2a9116bdab4ec17e1c1301b65a Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Thu, 19 Mar 2020 08:21:44 +0100 Subject: [PATCH 02/13] #26682 Disallow setting extension attributes as data array PHP CS Fix --- app/code/Magento/Quote/Model/ShippingMethodManagement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index 202eeb765216b..2f1880ec3f588 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -313,7 +313,7 @@ private function getShippingMethods(Quote $quote, $address) $extractedAddressData = $this->extractAddressData($address); if (array_key_exists('extension_attributes', $extractedAddressData)) { unset($extractedAddressData['extension_attributes']); - } + } $shippingAddress->addData($extractedAddressData); $shippingAddress->setCollectShippingRates(true); From bc18a8fd5141a2748b4938e2468413ba7a3625ba Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Thu, 30 Apr 2020 17:50:30 +0200 Subject: [PATCH 03/13] #27338 Add testmodule with extension attribute --- .../etc/extension_attributes.xml | 7 ++ .../etc/module.xml | 9 ++ .../registration.php | 6 + ...tEstimationWithExtensionAttributesTest.php | 116 ++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml create mode 100644 dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml create mode 100644 dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php create mode 100644 dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml new file mode 100644 index 0000000000000..4835532ade5c7 --- /dev/null +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml new file mode 100644 index 0000000000000..09b47a3669cf5 --- /dev/null +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php new file mode 100644 index 0000000000000..1b529e5bd08a1 --- /dev/null +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php @@ -0,0 +1,6 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_free_shipping.php + * @magentoApiDataFixture Magento/Sales/_files/quote.php + */ + public function testEstimateByExtendedAddress() + { + /** @var \Magento\Quote\Model\Quote $quote */ + $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); + $quote->load('test01', 'reserved_order_id'); + $cartId = $quote->getId(); + if (!$cartId) { + $this->fail('quote fixture failed'); + } + + /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ + $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) + ->create(); + $quoteIdMask->load($cartId, 'quote_id'); + //Use masked cart Id + $cartId = $quoteIdMask->getMaskedId(); + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/guest-carts/' . $cartId . '/estimate-shipping-methods', + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => 'V1', + 'operation' => self::SERVICE_NAME . 'EstimateByExtendedAddress', + ], + ]; + if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { + /** @var \Magento\Quote\Model\Quote\Address $address */ + $address = $quote->getBillingAddress(); + + $data = [ + AddressInterface::KEY_ID => (int)$address->getId(), + AddressInterface::KEY_REGION => $address->getRegion(), + AddressInterface::KEY_REGION_ID => $address->getRegionId(), + AddressInterface::KEY_REGION_CODE => $address->getRegionCode(), + AddressInterface::KEY_COUNTRY_ID => $address->getCountryId(), + AddressInterface::KEY_STREET => $address->getStreet(), + AddressInterface::KEY_COMPANY => $address->getCompany(), + AddressInterface::KEY_TELEPHONE => $address->getTelephone(), + AddressInterface::KEY_POSTCODE => $address->getPostcode(), + AddressInterface::KEY_CITY => $address->getCity(), + AddressInterface::KEY_FIRSTNAME => $address->getFirstname(), + AddressInterface::KEY_LASTNAME => $address->getLastname(), + AddressInterface::KEY_CUSTOMER_ID => $address->getCustomerId(), + AddressInterface::KEY_EMAIL => $address->getEmail(), + AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), + AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), + AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook(), + + 'custom_attributes' => [ + [ + 'attribute_code' => 'test_attribute', + 'value' => 1, + ], + ] + ]; + + $requestData = [ + 'cartId' => $cartId, + 'address' => $data + ]; + } else { + $requestData = [ + 'address' => [ + 'country_id' => "US", + 'postcode' => null, + 'region' => null, + 'region_id' => null + ], + ]; + } + // Cart must be anonymous (see fixture) + $this->assertEmpty($quote->getCustomerId()); + + $result = $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotEmpty($result); + $this->assertEquals(1, count($result)); + foreach ($result as $rate) { + $this->assertEquals("flatrate", $rate['carrier_code']); + $this->assertEquals(0, $rate['amount']); + } + } +} From 013bbc97b533856ac49607ed8a94c160dad32959 Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Thu, 30 Apr 2020 17:53:23 +0200 Subject: [PATCH 04/13] #27338 Adapt test case to supply extension attributes instead of custom attributes (still not failing with the fix reverted) --- .../GuestShipmentEstimationWithExtensionAttributesTest.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php index da1ac84e44e15..9e8e736602035 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php @@ -80,11 +80,8 @@ public function testEstimateByExtendedAddress() AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook(), - 'custom_attributes' => [ - [ - 'attribute_code' => 'test_attribute', - 'value' => 1, - ], + 'extension_attributes' => [ + 'test_attribute' => 1 ] ]; From 7d8638892f3e0b12c11d724dd2d6da8a1e27eaa2 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 5 May 2020 17:37:20 +0300 Subject: [PATCH 05/13] #27338: Test API functional for Extension Attribute of Shipping Addresses --- ...tEstimationWithExtensionAttributesTest.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php index 9e8e736602035..f59282529ada7 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Quote\Api; +use Magento\Framework\Api\ExtensibleDataInterface; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; use Magento\Quote\Api\Data\AddressInterface; @@ -26,6 +27,8 @@ protected function setUp() } /** + * @magentoAppIsolation enabled + * @magentoDbIsolation disabled * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_free_shipping.php * @magentoApiDataFixture Magento/Sales/_files/quote.php */ @@ -59,7 +62,7 @@ public function testEstimateByExtendedAddress() ]; if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { /** @var \Magento\Quote\Model\Quote\Address $address */ - $address = $quote->getBillingAddress(); + $address = $quote->getShippingAddress(); $data = [ AddressInterface::KEY_ID => (int)$address->getId(), @@ -79,9 +82,8 @@ public function testEstimateByExtendedAddress() AddressInterface::SAME_AS_BILLING => $address->getSameAsBilling(), AddressInterface::CUSTOMER_ADDRESS_ID => $address->getCustomerAddressId(), AddressInterface::SAVE_IN_ADDRESS_BOOK => $address->getSaveInAddressBook(), - - 'extension_attributes' => [ - 'test_attribute' => 1 + ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => [ + 'discounts' => [] ] ]; @@ -90,19 +92,24 @@ public function testEstimateByExtendedAddress() 'address' => $data ]; } else { + $requestData = [ 'address' => [ 'country_id' => "US", 'postcode' => null, 'region' => null, - 'region_id' => null - ], + 'region_id' => null, + 'extension_attributes' => [ + 'discounts' => [] + ] + ] ]; } // Cart must be anonymous (see fixture) $this->assertEmpty($quote->getCustomerId()); $result = $this->_webApiCall($serviceInfo, $requestData); + $this->assertNotEmpty($result); $this->assertEquals(1, count($result)); foreach ($result as $rate) { From 517bc6e0af4b69c3ab0a44dba914a4ca38ae40d8 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 5 May 2020 18:42:47 +0300 Subject: [PATCH 06/13] #27338: Test API functional for Extension Attribute of Shipping Addresses --- .../Api/GuestShipmentEstimationWithExtensionAttributesTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php index f59282529ada7..230c5ecfd43ba 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php @@ -105,6 +105,7 @@ public function testEstimateByExtendedAddress() ] ]; } + // Cart must be anonymous (see fixture) $this->assertEmpty($quote->getCustomerId()); From c29e3234b787eb3ea513ef49507c135b8bb921a0 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 5 May 2020 18:46:56 +0300 Subject: [PATCH 07/13] #27338: Changes for SalesRule/Model/Quote/Discount , for fix if exist Extension Attributes --- .../SalesRule/Model/Quote/Discount.php | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index a580a8f9d2eaa..22b4facc5eb2f 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -8,6 +8,7 @@ use Magento\Framework\App\ObjectManager; use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory; use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory; +use Magento\Quote\Api\Data\AddressExtensionFactory; /** * Discount totals calculation model. @@ -50,6 +51,11 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal */ private $discountDataInterfaceFactory; + /** + * @var AddressExtensionFactory + */ + private $addressExtensionFactory; + /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -57,6 +63,7 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory * @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory + * @param AddressExtensionFactory|null $addressExtensionFactory */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, @@ -64,7 +71,8 @@ public function __construct( \Magento\SalesRule\Model\Validator $validator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, RuleDiscountInterfaceFactory $discountInterfaceFactory = null, - DiscountDataInterfaceFactory $discountDataInterfaceFactory = null + DiscountDataInterfaceFactory $discountDataInterfaceFactory = null, + AddressExtensionFactory $addressExtensionFactory = null ) { $this->setCode(self::COLLECTOR_TYPE_CODE); $this->eventManager = $eventManager; @@ -75,6 +83,8 @@ public function __construct( ?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class); $this->discountDataInterfaceFactory = $discountDataInterfaceFactory ?: ObjectManager::getInstance()->get(DiscountDataInterfaceFactory::class); + $this->addressExtensionFactory = $addressExtensionFactory + ?: ObjectManager::getInstance()->get(AddressExtensionFactory::class); } /** @@ -84,6 +94,7 @@ public function __construct( * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment * @param \Magento\Quote\Model\Quote\Address\Total $total * @return $this + * @throws \Magento\Framework\Exception\NoSuchEntityException * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -119,7 +130,20 @@ public function collect( $address->setDiscountDescription([]); $items = $this->calculator->sortItemsByPriority($items, $address); - $address->getExtensionAttributes()->setDiscounts([]); + + if (!is_object($address->getExtensionAttributes())) { + $addressExtensionAttributes = $address->getExtensionAttributes(); + $addressExtension = $this->addressExtensionFactory->create(); + + foreach ($addressExtensionAttributes as $key => $value) { + $addressExtension->setData($key, $value); + } + $addressExtension->setDiscounts([]); + $address->setExtensionAttributes($addressExtension); + } else { + $address->getExtensionAttributes()->setDiscounts([]); + } + $addressDiscountAggregator = []; /** @var \Magento\Quote\Model\Quote\Item $item */ @@ -300,6 +324,7 @@ private function aggregateDiscountPerRule( } } } - $address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator)); + + $address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator)); } } From b60504e8dfe75dee6069adb5e12027e0b0f4fb3d Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 5 May 2020 18:49:30 +0300 Subject: [PATCH 08/13] #27338: Fix typo --- .../_files/Magento/TestModuleExtensionAttributes/etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml index 09b47a3669cf5..2318bf5c3c970 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml @@ -1,7 +1,7 @@ - + From 65c71534af4bffd86c09d7886770269470644509 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Thu, 7 May 2020 16:55:47 +0300 Subject: [PATCH 09/13] Revert changes --- .../SalesRule/Model/Quote/Discount.php | 29 ++----------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index 22b4facc5eb2f..8433f95a626e1 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -8,7 +8,6 @@ use Magento\Framework\App\ObjectManager; use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory; use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory; -use Magento\Quote\Api\Data\AddressExtensionFactory; /** * Discount totals calculation model. @@ -51,11 +50,6 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal */ private $discountDataInterfaceFactory; - /** - * @var AddressExtensionFactory - */ - private $addressExtensionFactory; - /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -63,7 +57,6 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency * @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory * @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory - * @param AddressExtensionFactory|null $addressExtensionFactory */ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, @@ -71,8 +64,7 @@ public function __construct( \Magento\SalesRule\Model\Validator $validator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, RuleDiscountInterfaceFactory $discountInterfaceFactory = null, - DiscountDataInterfaceFactory $discountDataInterfaceFactory = null, - AddressExtensionFactory $addressExtensionFactory = null + DiscountDataInterfaceFactory $discountDataInterfaceFactory = null ) { $this->setCode(self::COLLECTOR_TYPE_CODE); $this->eventManager = $eventManager; @@ -83,8 +75,6 @@ public function __construct( ?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class); $this->discountDataInterfaceFactory = $discountDataInterfaceFactory ?: ObjectManager::getInstance()->get(DiscountDataInterfaceFactory::class); - $this->addressExtensionFactory = $addressExtensionFactory - ?: ObjectManager::getInstance()->get(AddressExtensionFactory::class); } /** @@ -94,7 +84,6 @@ public function __construct( * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment * @param \Magento\Quote\Model\Quote\Address\Total $total * @return $this - * @throws \Magento\Framework\Exception\NoSuchEntityException * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -130,20 +119,7 @@ public function collect( $address->setDiscountDescription([]); $items = $this->calculator->sortItemsByPriority($items, $address); - - if (!is_object($address->getExtensionAttributes())) { - $addressExtensionAttributes = $address->getExtensionAttributes(); - $addressExtension = $this->addressExtensionFactory->create(); - - foreach ($addressExtensionAttributes as $key => $value) { - $addressExtension->setData($key, $value); - } - $addressExtension->setDiscounts([]); - $address->setExtensionAttributes($addressExtension); - } else { - $address->getExtensionAttributes()->setDiscounts([]); - } - + $address->getExtensionAttributes()->setDiscounts([]); $addressDiscountAggregator = []; /** @var \Magento\Quote\Model\Quote\Item $item */ @@ -324,7 +300,6 @@ private function aggregateDiscountPerRule( } } } - $address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator)); } } From 07538606525755713ffbe6691bd998735f640491 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 12 May 2020 12:48:29 +0300 Subject: [PATCH 10/13] Fix Static test --- .../etc/extension_attributes.xml | 6 ++++++ .../Magento/TestModuleExtensionAttributes/etc/module.xml | 6 ++++++ .../Magento/TestModuleExtensionAttributes/registration.php | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml index 4835532ade5c7..a09337803f56e 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml @@ -1,4 +1,10 @@ + diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml index 2318bf5c3c970..40a79a5e93729 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml @@ -1,4 +1,10 @@ + diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php index 1b529e5bd08a1..b28cc459b2e39 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php @@ -1,4 +1,8 @@ Date: Tue, 12 May 2020 15:01:46 +0300 Subject: [PATCH 11/13] Revert changes --- app/code/Magento/SalesRule/Model/Quote/Discount.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php index 8433f95a626e1..a580a8f9d2eaa 100644 --- a/app/code/Magento/SalesRule/Model/Quote/Discount.php +++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php @@ -300,6 +300,6 @@ private function aggregateDiscountPerRule( } } } - $address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator)); + $address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator)); } } From c38d99842781ec36accfcd40a3fefcfb4e76c9f9 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Mon, 18 May 2020 12:54:31 +0300 Subject: [PATCH 12/13] Refactoring. --- .../GuestShipmentEstimationWithExtensionAttributesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php index 230c5ecfd43ba..dc59a571aa136 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestShipmentEstimationWithExtensionAttributesTest.php @@ -21,7 +21,7 @@ class GuestShipmentEstimationWithExtensionAttributesTest extends WebapiAbstract */ private $objectManager; - protected function setUp() + protected function setUp(): void { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } @@ -32,7 +32,7 @@ protected function setUp() * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_free_shipping.php * @magentoApiDataFixture Magento/Sales/_files/quote.php */ - public function testEstimateByExtendedAddress() + public function testEstimateByExtendedAddress(): void { /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class); From 0518666727b48ce5b5a0373506312c53b74e452b Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Thu, 4 Jun 2020 10:59:22 +0300 Subject: [PATCH 13/13] Revert changes. Remove unused files. --- .../Quote/Model/ShippingMethodManagement.php | 8 +------- .../etc/extension_attributes.xml | 13 ------------- .../TestModuleExtensionAttributes/etc/module.xml | 15 --------------- .../registration.php | 10 ---------- 4 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml delete mode 100644 dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml delete mode 100644 dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index bbf9d5ee1fdd8..d9fa37c0185a9 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -316,13 +316,7 @@ private function getShippingMethods(Quote $quote, $address) { $output = []; $shippingAddress = $quote->getShippingAddress(); - - $extractedAddressData = $this->extractAddressData($address); - if (array_key_exists('extension_attributes', $extractedAddressData)) { - unset($extractedAddressData['extension_attributes']); - } - $shippingAddress->addData($extractedAddressData); - + $shippingAddress->addData($this->extractAddressData($address)); $shippingAddress->setCollectShippingRates(true); $this->totalsCollector->collectAddressTotals($quote, $shippingAddress); diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml deleted file mode 100644 index a09337803f56e..0000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/extension_attributes.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml deleted file mode 100644 index 40a79a5e93729..0000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/etc/module.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - diff --git a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php b/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php deleted file mode 100644 index b28cc459b2e39..0000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModuleExtensionAttributes/registration.php +++ /dev/null @@ -1,10 +0,0 @@ -