From 594fc93cdc92ca5648564718ce7a079d6afabdd8 Mon Sep 17 00:00:00 2001 From: Benoit Xylo Date: Thu, 31 Oct 2019 12:55:55 +0100 Subject: [PATCH 001/199] Set e-mail address for the PayPal guest quote's customer model This change sets an e-mail address on the customer model assigned to the guest quote prepared for further processing by PayPal module. It circumvents inability to place a guest order with PayPal Express when Automatic Asignment to Customer Group is enabled. Fixes #25399 --- app/code/Magento/Paypal/Model/Express/Checkout.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 389f20c757ae1..2b829086ac62e 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -1159,6 +1159,9 @@ protected function prepareGuestQuote() ->setCustomerEmail($quote->getBillingAddress()->getEmail()) ->setCustomerIsGuest(true) ->setCustomerGroupId(\Magento\Customer\Model\Group::NOT_LOGGED_IN_ID); + if ($quote->getCustomer()->getEmail() === null) { + $quote->getCustomer()->setEmail($quote->getBillingAddress()->getEmail()); + } return $this; } } From a99d980cebbfa1495de25aa91b9c70d86b2da7a6 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 7 Nov 2019 11:44:24 +0000 Subject: [PATCH 002/199] Fix for issue 25147 - Totals Information Management - setting quote shipping method when address method is not null --- .../Checkout/Model/TotalsInformationManagement.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/Model/TotalsInformationManagement.php b/app/code/Magento/Checkout/Model/TotalsInformationManagement.php index efb638d299864..a27a11ca22b78 100644 --- a/app/code/Magento/Checkout/Model/TotalsInformationManagement.php +++ b/app/code/Magento/Checkout/Model/TotalsInformationManagement.php @@ -52,9 +52,11 @@ public function calculate( $quote->setBillingAddress($addressInformation->getAddress()); } else { $quote->setShippingAddress($addressInformation->getAddress()); - $quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod( - $addressInformation->getShippingCarrierCode() . '_' . $addressInformation->getShippingMethodCode() - ); + if ($addressInformation->getShippingCarrierCode() && $addressInformation->getShippingMethodCode()) { + $quote->getShippingAddress()->setCollectShippingRates(true)->setShippingMethod( + $addressInformation->getShippingCarrierCode().'_'.$addressInformation->getShippingMethodCode() + ); + } } $quote->collectTotals(); From 042df4153f29e6dfb18604ac0ca72c4a0671ef58 Mon Sep 17 00:00:00 2001 From: vadim Date: Tue, 21 Jan 2020 14:37:22 +0200 Subject: [PATCH 003/199] #7720 --- .../Catalog/Model/ProductRepository.php | 4 +++- .../Catalog/Model/ProductRepositoryTest.php | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index d656a0a9ac5b4..ce6c2657836bb 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -543,7 +543,9 @@ public function save(ProductInterface $product, $saveOptions = false) if (!$ignoreLinksFlag && $ignoreLinksFlag !== null) { $productLinks = $product->getProductLinks(); } - $productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId(); + if (!isset($productDataArray['store_id'])) { + $productDataArray['store_id'] = (int) $this->storeManager->getStore()->getId(); + } $product = $this->initializeProductData($productDataArray, empty($existingProduct)); $this->processLinks($product, $productLinks); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php index fb07d08faca58..a1b869dcf785d 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php @@ -233,4 +233,24 @@ public function testCustomLayout(): void } $this->assertTrue($caughtException); } + + /** + * Tests product repository update should use provided store code. + * + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testProductUpdate(): void + { + $sku = 'simple'; + $nameUpdated = 'updated'; + + $product = $this->productRepository->get($sku, false, 0); + $product->setName($nameUpdated); + $this->productRepository->save($product); + $product = $this->productRepository->get($sku, false, 0); + self::assertEquals( + $nameUpdated, + $product->getName() + ); + } } From a039ff41d4938d06e507778aaac4983e12ae8421 Mon Sep 17 00:00:00 2001 From: vadim Date: Tue, 21 Jan 2020 14:37:22 +0200 Subject: [PATCH 004/199] 7720 --- .../Catalog/Model/ProductRepository.php | 8 ++- .../Test/Unit/Model/ProductRepositoryTest.php | 65 ++++++++++++++++++- .../Catalog/Model/ProductRepositoryTest.php | 20 ++++++ 3 files changed, 89 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index d656a0a9ac5b4..3979a6566966a 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -30,7 +30,8 @@ use Magento\Framework\Exception\ValidatorException; /** - * Product Repository. + * @inheritdoc + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ @@ -543,7 +544,9 @@ public function save(ProductInterface $product, $saveOptions = false) if (!$ignoreLinksFlag && $ignoreLinksFlag !== null) { $productLinks = $product->getProductLinks(); } - $productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId(); + if (!isset($productDataArray['store_id'])) { + $productDataArray['store_id'] = (int) $this->storeManager->getStore()->getId(); + } $product = $this->initializeProductData($productDataArray, empty($existingProduct)); $this->processLinks($product, $productLinks); @@ -735,6 +738,7 @@ private function getCollectionProcessor() { if (!$this->collectionProcessor) { $this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get( + // phpstan:ignore "Class Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor not found." \Magento\Catalog\Model\Api\SearchCriteria\ProductCollectionProcessor::class ); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 0dc294e139d3e..02920a9797188 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -46,8 +46,8 @@ use PHPUnit_Framework_MockObject_MockObject as MockObject; /** - * Class ProductRepositoryTest - * @package Magento\Catalog\Test\Unit\Model + * Test for \Magento\Catalog\Model\ProductRepository. + * * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -291,6 +291,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); + $storeMock->method('getId')->willReturn('1'); $storeMock->expects($this->any())->method('getWebsiteId')->willReturn('1'); $storeMock->expects($this->any())->method('getCode')->willReturn(Store::ADMIN_CODE); $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeMock); @@ -345,6 +346,66 @@ function ($value) { $this->objectManager->setBackwardCompatibleProperty($this->model, 'mediaProcessor', $mediaProcessor); } + /** + * Test save product with store id 0 + * + * @param array $productData + * @return void + * @dataProvider getProductData + */ + public function testSaveForAllStoreViewScope(array $productData): void + { + $this->productFactory->method('create')->willReturn($this->product); + $this->product->method('getSku')->willReturn($productData['sku']); + $this->extensibleDataObjectConverter + ->expects($this->once()) + ->method('toNestedArray') + ->willReturn($productData); + $this->resourceModel->method('getIdBySku')->willReturn(100); + $this->resourceModel->expects($this->once())->method('validate')->willReturn(true); + $this->product->expects($this->at(14))->method('setData')->with('store_id', $productData['store_id']); + + $this->model->save($this->product); + } + + /** + * Product data provider + * + * @return array + */ + public function getProductData(): array + { + return [ + [ + [ + 'sku' => 'sku', + 'name' => 'product', + 'store_id' => 0, + ], + ], + ]; + } + + /** + * Test save product without store + * + * @return void + */ + public function testSaveWithoutStoreId(): void + { + $this->productFactory->method('create')->willReturn($this->product); + $this->product->method('getSku')->willReturn($this->productData['sku']); + $this->extensibleDataObjectConverter + ->expects($this->once()) + ->method('toNestedArray') + ->willReturn($this->productData); + $this->resourceModel->method('getIdBySku')->willReturn(100); + $this->resourceModel->expects($this->once())->method('validate')->willReturn(true); + $this->product->expects($this->at(15))->method('setData')->with('store_id', 1); + + $this->model->save($this->product); + } + /** * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage The product that was requested doesn't exist. Verify the product and try again. diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php index fb07d08faca58..e85837eb59ae4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php @@ -233,4 +233,24 @@ public function testCustomLayout(): void } $this->assertTrue($caughtException); } + + /** + * Tests product repository update should use provided store code. + * + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testProductUpdate(): void + { + $sku = 'simple'; + $nameUpdated = 'updated'; + + $product = $this->productRepository->get($sku, false, 0); + $product->setName($nameUpdated); + $this->productRepository->save($product); + $product = $this->productRepository->get($sku, false, 0); + $this->assertEquals( + $nameUpdated, + $product->getName() + ); + } } From 7a04c04bec1fa3525d8b43ca684e13da3cb37974 Mon Sep 17 00:00:00 2001 From: Pascal Brouwers Date: Fri, 24 Jan 2020 15:42:02 +0100 Subject: [PATCH 005/199] issue/26526 Fix orderRepository does not check if there are no extensionAttributes --- app/code/Magento/Sales/Model/OrderRepository.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/Sales/Model/OrderRepository.php b/app/code/Magento/Sales/Model/OrderRepository.php index f93de4c32d888..baac39b333712 100644 --- a/app/code/Magento/Sales/Model/OrderRepository.php +++ b/app/code/Magento/Sales/Model/OrderRepository.php @@ -157,6 +157,9 @@ public function get($id) private function setOrderTaxDetails(OrderInterface $order) { $extensionAttributes = $order->getExtensionAttributes(); + if ($extensionAttributes === null) { + $extensionAttributes = $this->orderExtensionFactory->create(); + } $orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getEntityId()); $appliedTaxes = $orderTaxDetails->getAppliedTaxes(); @@ -180,6 +183,9 @@ private function setOrderTaxDetails(OrderInterface $order) private function setPaymentAdditionalInfo(OrderInterface $order): void { $extensionAttributes = $order->getExtensionAttributes(); + if ($extensionAttributes === null) { + $extensionAttributes = $this->orderExtensionFactory->create(); + } $paymentAdditionalInformation = $order->getPayment()->getAdditionalInformation(); $objects = []; From 13af48ab3e53f9ec4d2d29dec28d39cffd7c9e3b Mon Sep 17 00:00:00 2001 From: vadim Date: Mon, 27 Jan 2020 11:34:41 +0200 Subject: [PATCH 006/199] #7720 fix cs --- .../Test/Unit/Model/ProductRepositoryTest.php | 30 +++++--- .../Catalog/Model/ProductRepositoryTest.php | 68 +++++++++++++++---- 2 files changed, 74 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 02920a9797188..792557f14a5bc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -54,6 +54,16 @@ */ class ProductRepositoryTest extends TestCase { + private const STUB_STORE_ID = 1; + + private const STUB_STORE_ID_GLOBAL = 0; + + private const STUB_PRODUCT_ID = 100; + + private const STUB_PRODUCT_NAME = 'name'; + + private const STUB_PRODUCT_SKU = 'sku'; + /** * @var Product|MockObject */ @@ -291,7 +301,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods([]) ->getMockForAbstractClass(); - $storeMock->method('getId')->willReturn('1'); + $storeMock->method('getId')->willReturn(self::STUB_STORE_ID); $storeMock->expects($this->any())->method('getWebsiteId')->willReturn('1'); $storeMock->expects($this->any())->method('getCode')->willReturn(Store::ADMIN_CODE); $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeMock); @@ -347,7 +357,7 @@ function ($value) { } /** - * Test save product with store id 0 + * Test save product with global store id * * @param array $productData * @return void @@ -361,9 +371,10 @@ public function testSaveForAllStoreViewScope(array $productData): void ->expects($this->once()) ->method('toNestedArray') ->willReturn($productData); - $this->resourceModel->method('getIdBySku')->willReturn(100); + $this->resourceModel->method('getIdBySku')->willReturn(self::STUB_PRODUCT_ID); $this->resourceModel->expects($this->once())->method('validate')->willReturn(true); - $this->product->expects($this->at(14))->method('setData')->with('store_id', $productData['store_id']); + $this->product->expects($this->at(14))->method('setData') + ->with('store_id', $productData['store_id']); $this->model->save($this->product); } @@ -378,9 +389,9 @@ public function getProductData(): array return [ [ [ - 'sku' => 'sku', - 'name' => 'product', - 'store_id' => 0, + 'sku' => self::STUB_PRODUCT_SKU, + 'name' => self::STUB_PRODUCT_NAME, + 'store_id' => self::STUB_STORE_ID_GLOBAL, ], ], ]; @@ -399,9 +410,10 @@ public function testSaveWithoutStoreId(): void ->expects($this->once()) ->method('toNestedArray') ->willReturn($this->productData); - $this->resourceModel->method('getIdBySku')->willReturn(100); + $this->resourceModel->method('getIdBySku')->willReturn(self::STUB_PRODUCT_ID); $this->resourceModel->expects($this->once())->method('validate')->willReturn(true); - $this->product->expects($this->at(15))->method('setData')->with('store_id', 1); + $this->product->expects($this->at(15))->method('setData') + ->with('store_id', self::STUB_STORE_ID); $this->model->save($this->product); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php index e85837eb59ae4..a63d4c5f02d7e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php @@ -7,15 +7,12 @@ namespace Magento\Catalog\Model; -use Magento\Backend\Model\Auth; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\ResourceModel\Product as ProductResource; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Exception\LocalizedException; use Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager; use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestFramework\Bootstrap as TestBootstrap; -use Magento\Framework\Acl\Builder; /** * Provide tests for ProductRepository model. @@ -26,6 +23,16 @@ */ class ProductRepositoryTest extends \PHPUnit\Framework\TestCase { + private const STUB_STORE_ID = 1; + + private const STUB_STORE_ID_GLOBAL = 0; + + private const STUB_PRODUCT_NAME = 'Simple Product'; + + private const STUB_UPDATED_PRODUCT_NAME = 'updated'; + + private const STUB_PRODUCT_SKU = 'simple'; + /** * Test subject. * @@ -235,22 +242,53 @@ public function testCustomLayout(): void } /** - * Tests product repository update should use provided store code. + * Tests product repository update * + * @dataProvider productUpdateDataProvider * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @param int $storeId + * @param int $checkStoreId + * @param string $expectedNameStore + * @param string $expectedNameCheckedStore */ - public function testProductUpdate(): void - { - $sku = 'simple'; - $nameUpdated = 'updated'; + public function testProductUpdate( + int $storeId, + int $checkStoreId, + string $expectedNameStore, + string $expectedNameCheckedStore + ): void { + $sku = self::STUB_PRODUCT_SKU; - $product = $this->productRepository->get($sku, false, 0); - $product->setName($nameUpdated); + $product = $this->productRepository->get($sku, false, $storeId); + $product->setName(self::STUB_UPDATED_PRODUCT_NAME); $this->productRepository->save($product); - $product = $this->productRepository->get($sku, false, 0); - $this->assertEquals( - $nameUpdated, - $product->getName() - ); + $productNameStoreId = $this->productRepository->get($sku, false, $storeId)->getName(); + $productNameCheckedStoreId = $this->productRepository->get($sku, false, $checkStoreId)->getName(); + + $this->assertEquals($expectedNameStore, $productNameStoreId); + $this->assertEquals($expectedNameCheckedStore, $productNameCheckedStoreId); + } + + /** + * Product update data provider + * + * @return array + */ + public function productUpdateDataProvider(): array + { + return [ + 'Updating for global store' => [ + self::STUB_STORE_ID_GLOBAL, + self::STUB_STORE_ID, + self::STUB_UPDATED_PRODUCT_NAME, + self::STUB_UPDATED_PRODUCT_NAME, + ], + 'Updating for store' => [ + self::STUB_STORE_ID, + self::STUB_STORE_ID_GLOBAL, + self::STUB_UPDATED_PRODUCT_NAME, + self::STUB_PRODUCT_NAME, + ], + ]; } } From 156b3c285baba8df7ec04853746fbf44e8ed6d83 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 10 Feb 2020 12:00:33 +0200 Subject: [PATCH 007/199] magento/magento2#7720: fix integration test --- .../Type/MultiStoreConfigurableViewOnProductPageTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php index c1adf0ef1d2be..28c21254c7d9d 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php @@ -17,6 +17,7 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Store\ExecuteInStoreContext; +use Magento\Store\Api\StoreRepositoryInterface; use PHPUnit\Framework\TestCase; /** @@ -47,6 +48,9 @@ class MultiStoreConfigurableViewOnProductPageTest extends TestCase /** @var ExecuteInStoreContext */ private $executeInStoreContext; + /** @var StoreRepositoryInterface */ + private $storeRepository; + /** * @inheritdoc */ @@ -62,6 +66,7 @@ protected function setUp() $this->serializer = $this->objectManager->get(SerializerInterface::class); $this->productResource = $this->objectManager->get(ProductResource::class); $this->executeInStoreContext = $this->objectManager->get(ExecuteInStoreContext::class); + $this->storeRepository = $this->objectManager->get(StoreRepositoryInterface::class); } /** @@ -182,9 +187,11 @@ public function assertProductConfig($expectedProducts): void */ private function prepareConfigurableProduct(string $sku, string $storeCode): void { + $storeId = $this->storeRepository->get($storeCode)->getId(); $product = $this->productRepository->get($sku, false, null, true); $productToUpdate = $product->getTypeInstance()->getUsedProductCollection($product) - ->setPageSize(1)->getFirstItem(); + ->addStoreFilter($storeId)->setPageSize(1)->getFirstItem(); + $this->assertNotEmpty($productToUpdate->getData(), 'Configurable product does not have a child'); $this->executeInStoreContext->execute($storeCode, [$this, 'setProductDisabled'], $productToUpdate); } From 28b5d9d59803825e0bc9e340716cd269c7e26b6a Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 10 Feb 2020 15:38:19 +0200 Subject: [PATCH 008/199] magento/magento2#7720: improve integration test fix --- .../Type/MultiStoreConfigurableViewOnProductPageTest.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php index 28c21254c7d9d..167a32fcb2f45 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/MultiStoreConfigurableViewOnProductPageTest.php @@ -17,7 +17,6 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Store\ExecuteInStoreContext; -use Magento\Store\Api\StoreRepositoryInterface; use PHPUnit\Framework\TestCase; /** @@ -48,9 +47,6 @@ class MultiStoreConfigurableViewOnProductPageTest extends TestCase /** @var ExecuteInStoreContext */ private $executeInStoreContext; - /** @var StoreRepositoryInterface */ - private $storeRepository; - /** * @inheritdoc */ @@ -66,7 +62,6 @@ protected function setUp() $this->serializer = $this->objectManager->get(SerializerInterface::class); $this->productResource = $this->objectManager->get(ProductResource::class); $this->executeInStoreContext = $this->objectManager->get(ExecuteInStoreContext::class); - $this->storeRepository = $this->objectManager->get(StoreRepositoryInterface::class); } /** @@ -187,10 +182,10 @@ public function assertProductConfig($expectedProducts): void */ private function prepareConfigurableProduct(string $sku, string $storeCode): void { - $storeId = $this->storeRepository->get($storeCode)->getId(); + $store = $this->storeManager->getStore($storeCode); $product = $this->productRepository->get($sku, false, null, true); $productToUpdate = $product->getTypeInstance()->getUsedProductCollection($product) - ->addStoreFilter($storeId)->setPageSize(1)->getFirstItem(); + ->addStoreFilter($store)->setPageSize(1)->getFirstItem(); $this->assertNotEmpty($productToUpdate->getData(), 'Configurable product does not have a child'); $this->executeInStoreContext->execute($storeCode, [$this, 'setProductDisabled'], $productToUpdate); From 3f616adb872b020c2ec132f2998d806ef7da2b8a Mon Sep 17 00:00:00 2001 From: Ashoka de Wit Date: Thu, 26 Mar 2020 12:19:06 +0800 Subject: [PATCH 009/199] Convert MSRP currency of configurable product options The MSRP of configurable products is updated in Javascript when an option is chosen. Javascript uses an object with prices of the options. The prices in this object are converted to the chosen currency. MSRP prices however were not converted, leading to the price being displayed in a wrong currency. --- .../Block/Product/View/Type/Configurable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 55c0c8f6ca4ce..7fe0aca43c5b8 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -321,7 +321,7 @@ protected function getOptionPrices() 'tierPrices' => $tierPrices, 'msrpPrice' => [ 'amount' => $this->localeFormat->getNumber( - $product->getMsrp() + $this->priceCurrency->convertAndRound($product->getMsrp()) ), ], ]; From c56eb37dfa0bae801957f2549e6888cd0a579816 Mon Sep 17 00:00:00 2001 From: Dmitri Mackert Date: Fri, 27 Mar 2020 18:41:00 +0100 Subject: [PATCH 010/199] MAGETWO-2745: added appEmulation to the obserber --- app/code/Magento/Sitemap/Model/Observer.php | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index ce74d738c4bc3..a87cb864532d9 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -3,11 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sitemap\Model; -use Magento\Sitemap\Model\EmailNotification as SitemapEmail; +use Magento\Framework\App\Area; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Sitemap\Model\EmailNotification as SitemapEmail; use Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory; +use Magento\Store\Model\App\Emulation; use Magento\Store\Model\ScopeInterface; /** @@ -61,20 +65,28 @@ class Observer */ private $emailNotification; + /** + * @var Emulation + */ + private $appEmulation; + /** * Observer constructor. * @param ScopeConfigInterface $scopeConfig * @param CollectionFactory $collectionFactory * @param EmailNotification $emailNotification + * @param Emulation $appEmulation */ public function __construct( ScopeConfigInterface $scopeConfig, CollectionFactory $collectionFactory, - SitemapEmail $emailNotification + SitemapEmail $emailNotification, + Emulation $appEmulation ) { $this->scopeConfig = $scopeConfig; $this->collectionFactory = $collectionFactory; $this->emailNotification = $emailNotification; + $this->appEmulation = $appEmulation; } /** @@ -105,7 +117,13 @@ public function scheduledGenerateSitemaps() foreach ($collection as $sitemap) { /* @var $sitemap \Magento\Sitemap\Model\Sitemap */ try { + $this->appEmulation->startEnvironmentEmulation( + $sitemap->getStoreId(), + Area::AREA_FRONTEND, + true + ); $sitemap->generateXml(); + $this->appEmulation->stopEnvironmentEmulation(); } catch (\Exception $e) { $errors[] = $e->getMessage(); } From 2b86774ff29f132f7e89982695d13d4b3378c5ee Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Tue, 7 Apr 2020 09:52:34 +0300 Subject: [PATCH 011/199] Created action group for cancel created orders --- .../Test/CheckCheckoutSuccessPageTest.xml | 8 ++- ...nOrderChangeByCustomerEmailActionGroup.xml | 61 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index eb49f53921ea4..5fbe30fb93c80 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -27,10 +27,16 @@ + + + + + + + - diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml new file mode 100644 index 0000000000000..186d8bffbd502 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml @@ -0,0 +1,61 @@ + + + + + + + Goes to the Admin Orders grid page and changes all orders found by Customer Email field. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 83a4f097281860eaa59425feffb988f16000f0c9 Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Tue, 7 Apr 2020 10:23:43 +0300 Subject: [PATCH 012/199] Moved going to order page and clearing the filters outside action group --- .../Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml | 2 ++ .../AdminOrderChangeByCustomerEmailActionGroup.xml | 13 +------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index 5fbe30fb93c80..55871ae23ac5d 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -29,6 +29,8 @@ + + diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml index 186d8bffbd502..b74fcab2c095f 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml @@ -10,7 +10,7 @@ - Goes to the Admin Orders grid page and changes all orders found by Customer Email field. + Changes all orders found by Customer Email field. @@ -18,17 +18,6 @@ - - - - - - Date: Tue, 7 Apr 2020 10:42:27 +0300 Subject: [PATCH 013/199] Created new action group to show new column in admin grid --- .../Test/CheckCheckoutSuccessPageTest.xml | 3 +++ ...nOrderChangeByCustomerEmailActionGroup.xml | 14 +---------- .../AdminGridColumnShowActionGroup.xml | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridColumnShowActionGroup.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index 55871ae23ac5d..07ece70c157e2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -31,6 +31,9 @@ + + + diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml index b74fcab2c095f..b2796cb5733aa 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml @@ -10,7 +10,7 @@ - Changes all orders found by Customer Email field. + Changes all orders found by Customer Email field on Admin Order Grid page. @@ -18,18 +18,6 @@ - - - - - - + + + + + + Shows new column on Admin Grid page. + + + + + + + + + + + + From 24f9954c57deaa5d61ff6a77609b0fb36aa9fe51 Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Fri, 10 Apr 2020 10:49:10 +0300 Subject: [PATCH 014/199] Created action group for massive actions in order admin grid --- .../Mftf/Test/CheckCheckoutSuccessPageTest.xml | 7 +++++-- ...=> AdminOrderBulkActionOnGridActionGroup.xml} | 16 ++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) rename app/code/Magento/Sales/Test/Mftf/ActionGroup/{AdminOrderChangeByCustomerEmailActionGroup.xml => AdminOrderBulkActionOnGridActionGroup.xml} (58%) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index 07ece70c157e2..7c5aa014bb375 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -34,9 +34,12 @@ - - + + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml similarity index 58% rename from app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml rename to app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml index b2796cb5733aa..1a2aebef763a0 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderChangeByCustomerEmailActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml @@ -7,28 +7,16 @@ --> - + - Changes all orders found by Customer Email field on Admin Order Grid page. + Massive action for all rows on Admin Order Grid page. - - - - - - - - From fd3e8133f7b8cd541d6305ce0f2722817ba98d2d Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Fri, 10 Apr 2020 16:59:44 +0300 Subject: [PATCH 015/199] Moved bulk action group to Ui module to use in any admin grid --- .../Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml | 4 +++- .../Test/Mftf/ActionGroup/AdminGridBulkActionGroup.xml} | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) rename app/code/Magento/{Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml => Ui/Test/Mftf/ActionGroup/AdminGridBulkActionGroup.xml} (79%) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index 7c5aa014bb375..d836d6b046d3b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -39,7 +39,9 @@ - + + + diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridBulkActionGroup.xml similarity index 79% rename from app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml rename to app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridBulkActionGroup.xml index 1a2aebef763a0..9db9ea7becfc8 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderBulkActionOnGridActionGroup.xml +++ b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminGridBulkActionGroup.xml @@ -7,18 +7,18 @@ --> - + - Massive action for all rows on Admin Order Grid page. + Massive action for all rows on Admin Grid page. - + - + From 939ced035ae447f69bc31435ab7e3068503d1af4 Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Fri, 10 Apr 2020 18:04:07 +0300 Subject: [PATCH 016/199] Cancel created orders after CheckCheckoutSuccessPageAsGuestTest --- .../Mftf/Test/CheckCheckoutSuccessPageTest.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index d836d6b046d3b..7d0176eb309db 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -163,7 +163,23 @@ + + + + + + + + + + + + + + + + From 756f2dce55fd40c534fc00c131a9cc599a0f837a Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Sat, 11 Apr 2020 13:15:46 +0300 Subject: [PATCH 017/199] Updated CheckCheckoutSuccessPageAsGuestTest after update branch --- .../CheckCheckoutSuccessPageAsGuestTest.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml index febeaa05be43e..d6a3cc791d6e0 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml @@ -23,7 +23,23 @@ + + + + + + + + + + + + + + + + From d63b5d8ebf71d461dea07ecac508790127064e65 Mon Sep 17 00:00:00 2001 From: Evgeny Levinsky Date: Sat, 11 Apr 2020 13:41:40 +0300 Subject: [PATCH 018/199] Added wait action in the end of AdminOrdersGridClearFiltersActionGroup --- .../Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml | 1 - .../Test/AssociatedProductToConfigurableOutOfStockTest.xml | 3 --- .../CheckCheckoutSuccessPageAsGuestTest.xml | 1 - .../CheckCheckoutSuccessPageAsRegisterCustomerTest.xml | 1 - .../ActionGroup/AdminOrdersGridClearFiltersActionGroup.xml | 1 + .../Mftf/Test/AdminMassOrdersCancelCompleteAndClosedTest.xml | 3 --- .../Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml | 3 --- .../Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml | 3 --- .../Test/AdminMassOrdersHoldOnPendingAndProcessingTest.xml | 3 --- .../Test/Mftf/Test/AdminMassOrdersReleasePendingOrderTest.xml | 3 --- .../Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml | 3 --- .../Test/Mftf/Test/AdminOrdersReleaseInUnholdStatusTest.xml | 3 --- 12 files changed, 1 insertion(+), 27 deletions(-) diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml index 147f2fa1dfaed..efe62d23191ce 100644 --- a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml +++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml @@ -34,7 +34,6 @@ - diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml index b291fb46ae71c..1f82a78d498c2 100644 --- a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml +++ b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml @@ -115,11 +115,8 @@ - - - diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml index d6a3cc791d6e0..3b15b9b4e0449 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsGuestTest.xml @@ -26,7 +26,6 @@ - diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsRegisterCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsRegisterCustomerTest.xml index 66967ad95bf40..fefab1a240f34 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsRegisterCustomerTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsRegisterCustomerTest.xml @@ -29,7 +29,6 @@ - diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrdersGridClearFiltersActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrdersGridClearFiltersActionGroup.xml index b301864212c8b..877f7946d7609 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrdersGridClearFiltersActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrdersGridClearFiltersActionGroup.xml @@ -16,5 +16,6 @@ + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelCompleteAndClosedTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelCompleteAndClosedTest.xml index a89e9f7ce6ebe..b19b0cd31a9ca 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelCompleteAndClosedTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelCompleteAndClosedTest.xml @@ -63,10 +63,7 @@ - - - diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml index 45cbe23042e03..b8455cc5ea71f 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml @@ -63,10 +63,7 @@ - - - diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml index 22b2d69a73090..e0c03d1f915f5 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml @@ -50,10 +50,7 @@ - - - diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnPendingAndProcessingTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnPendingAndProcessingTest.xml index 4b690a00ee9ed..47dc3bfb089bd 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnPendingAndProcessingTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnPendingAndProcessingTest.xml @@ -60,10 +60,7 @@ - - - diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersReleasePendingOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersReleasePendingOrderTest.xml index e1d934f794142..ebe3644901aa4 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersReleasePendingOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersReleasePendingOrderTest.xml @@ -47,10 +47,7 @@ - - - diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml index 86a3e381cb237..543f282bd59b2 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml @@ -46,10 +46,7 @@ - - - diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminOrdersReleaseInUnholdStatusTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminOrdersReleaseInUnholdStatusTest.xml index bfd75a69b81d6..e7bb7ec01ccc2 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminOrdersReleaseInUnholdStatusTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminOrdersReleaseInUnholdStatusTest.xml @@ -52,10 +52,7 @@ - - - From 303bd64e3c1a7281be08d3b73feb995ef580e61d Mon Sep 17 00:00:00 2001 From: Ievgen Shakhsuvarov Date: Tue, 5 May 2020 16:30:26 -0500 Subject: [PATCH 019/199] magento/magento2#28116: RequireJS resolver sometimes fails to detect blocked resources --- lib/web/mage/requirejs/resolver.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/web/mage/requirejs/resolver.js b/lib/web/mage/requirejs/resolver.js index 5ba1f1351bcf6..8e1757d30f572 100644 --- a/lib/web/mage/requirejs/resolver.js +++ b/lib/web/mage/requirejs/resolver.js @@ -37,6 +37,16 @@ define([ return registry[module.id] && (registry[module.id].inited || registry[module.id].error); } + /** + * Checks if provided module had path fallback triggered. + * + * @param {Object} module - Module to be checked. + * @return {Boolean} + */ + function isPathFallback(module) { + return registry[module.id] && registry[module.id].events.error; + } + /** * Checks if provided module has unresolved dependencies. * @@ -48,7 +58,8 @@ define([ return false; } - return module.depCount > _.filter(module.depMaps, isRejected).length; + return module.depCount > + (_.filter(module.depMaps, isRejected).length + _.filter(module.depMaps, isPathFallback).length); } /** From 44d88e64f70134280616bcc9471f74283fdef44f Mon Sep 17 00:00:00 2001 From: Pieter Zandbergen Date: Sun, 26 Jul 2020 10:23:30 +0200 Subject: [PATCH 020/199] Update Curl to respect case-insensitive headers According to RFC 2616 header names are case-insensitive: "Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive." - see https://tools.ietf.org/html/rfc2616#section-4.2 The "Set-Cookie" comparison in the previous version is case-sensitive and can cause problems with some (rare) HTTP servers. --- lib/internal/Magento/Framework/HTTP/Client/Curl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index 60825e231504d..d20dbf2142ec7 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -453,11 +453,11 @@ protected function parseHeaders($ch, $data) } if (strlen($name)) { - if ("Set-Cookie" == $name) { - if (!isset($this->_responseHeaders[$name])) { - $this->_responseHeaders[$name] = []; + if ("set-cookie" == strtolower($name)) { + if (!isset($this->_responseHeaders['Set-Cookie'])) { + $this->_responseHeaders['Set-Cookie'] = []; } - $this->_responseHeaders[$name][] = $value; + $this->_responseHeaders['Set-Cookie'][] = $value; } else { $this->_responseHeaders[$name] = $value; } From 375b129374fb83ba4993c67cb893835da91032ec Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Wed, 29 Jul 2020 09:12:06 +0300 Subject: [PATCH 021/199] magento/magento2#28117 RequireJS resolver sometimes fails to detect blocked resources Fix static tests --- lib/web/mage/requirejs/resolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/mage/requirejs/resolver.js b/lib/web/mage/requirejs/resolver.js index 8e1757d30f572..9818bc00c1343 100644 --- a/lib/web/mage/requirejs/resolver.js +++ b/lib/web/mage/requirejs/resolver.js @@ -59,7 +59,7 @@ define([ } return module.depCount > - (_.filter(module.depMaps, isRejected).length + _.filter(module.depMaps, isPathFallback).length); + _.filter(module.depMaps, isRejected).length + _.filter(module.depMaps, isPathFallback).length; } /** From ba6513fa9b8777dd5a1a89a9b542ec54978ef534 Mon Sep 17 00:00:00 2001 From: Pieter Zandbergen Date: Wed, 29 Jul 2020 21:12:40 +0200 Subject: [PATCH 022/199] Update lib/internal/Magento/Framework/HTTP/Client/Curl.php Co-authored-by: Ihor Sviziev --- lib/internal/Magento/Framework/HTTP/Client/Curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index d20dbf2142ec7..195ce3a63a231 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -453,7 +453,7 @@ protected function parseHeaders($ch, $data) } if (strlen($name)) { - if ("set-cookie" == strtolower($name)) { + if ("set-cookie" === strtolower($name)) { if (!isset($this->_responseHeaders['Set-Cookie'])) { $this->_responseHeaders['Set-Cookie'] = []; } From 552e0c1fbd1367e7ecb7fb421b8057060663a3af Mon Sep 17 00:00:00 2001 From: Pieter Zandbergen Date: Sun, 2 Aug 2020 09:41:01 +0200 Subject: [PATCH 023/199] Updated cUrl client to accept case-insensitive Set-Cookie headers including tests --- .../Magento/Framework/HTTP/Client/Curl.php | 8 +- .../HTTP/Test/Unit/Client/CurlMockTest.php | 86 +++++++++++++++++++ .../Unit/Client/_files/curl_exec_mock.php | 51 +++++++++++ .../Client/_files/curl_response_cookies.txt | 14 +++ 4 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 lib/internal/Magento/Framework/HTTP/Test/Unit/Client/CurlMockTest.php create mode 100644 lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_exec_mock.php create mode 100644 lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_response_cookies.txt diff --git a/lib/internal/Magento/Framework/HTTP/Client/Curl.php b/lib/internal/Magento/Framework/HTTP/Client/Curl.php index 60825e231504d..4d78712175156 100644 --- a/lib/internal/Magento/Framework/HTTP/Client/Curl.php +++ b/lib/internal/Magento/Framework/HTTP/Client/Curl.php @@ -453,11 +453,11 @@ protected function parseHeaders($ch, $data) } if (strlen($name)) { - if ("Set-Cookie" == $name) { - if (!isset($this->_responseHeaders[$name])) { - $this->_responseHeaders[$name] = []; + if ('set-cookie' === strtolower($name)) { + if (!isset($this->_responseHeaders['Set-Cookie'])) { + $this->_responseHeaders['Set-Cookie'] = []; } - $this->_responseHeaders[$name][] = $value; + $this->_responseHeaders['Set-Cookie'][] = $value; } else { $this->_responseHeaders[$name] = $value; } diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/CurlMockTest.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/CurlMockTest.php new file mode 100644 index 0000000000000..acb068b581e02 --- /dev/null +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/CurlMockTest.php @@ -0,0 +1,86 @@ +model = new CurlMock(); + } + + /** + * Handle Curl response + * + * @param string $response + * @return string + */ + private function handleResponse(string $response): string + { + // Make sure we use valid newlines + $response = explode("\r\n\r\n", str_replace("\n", "\r\n", $response), 2); + + // Parse headers + $headers = explode("\r\n", $response[0]); + foreach ($headers as $header) { + call_user_func([$this->model, 'parseHeaders'], $this->model->getResource(), $header); + } + + // Return body + return $response[1] ?? ''; + } + + /** + * Check that HTTP client parses cookies. + * + * @param string $response + * @dataProvider cookiesDataProvider + */ + public function testCookies($response) + { + self::$curlExectClosure = function () use ($response) { + $this->handleResponse($response); + }; + $this->model->get('http://127.0.0.1/test'); + $cookies = $this->model->getCookies(); + $this->assertIsArray($cookies); + $this->assertEquals([ + 'Normal' => 'OK', + 'Uppercase' => 'OK', + 'Lowercase' => 'OK', + ], $cookies); + } + + /** + * @return array + */ + public function cookiesDataProvider() + { + return [ + [file_get_contents(__DIR__ . '/_files/curl_response_cookies.txt')], + ]; + } +} diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_exec_mock.php b/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_exec_mock.php new file mode 100644 index 0000000000000..95e035d9366ba --- /dev/null +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_exec_mock.php @@ -0,0 +1,51 @@ +_ch; + } +} diff --git a/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_response_cookies.txt b/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_response_cookies.txt new file mode 100644 index 0000000000000..d68d286bb4de8 --- /dev/null +++ b/lib/internal/Magento/Framework/HTTP/Test/Unit/Client/_files/curl_response_cookies.txt @@ -0,0 +1,14 @@ +HTTP/1.1 200 OK +Server: Apache +X-Frame-Options: SAMEORIGIN +Strict-Transport-Security: max-age=14400 +Strict-Transport-Security: max-age=14400 +Content-Type: text/html; charset=UTF-8 +Date: Mon, 22 Apr 2013 09:52:36 GMT +Content-Length: 8 +Connection: keep-alive +Set-Cookie: Normal=OK +SET-COOKIE: Uppercase=OK +set-cookie: Lowercase=OK + +VERIFIED From 4f2d8de0f36132cab835e5af3bc88d461e87967f Mon Sep 17 00:00:00 2001 From: Shankar Konar Date: Thu, 6 Aug 2020 11:47:05 +0530 Subject: [PATCH 024/199] Added sticky in lac banner --- .../frontend/templates/html/notices.phtml | 4 +- .../view/frontend/web/css/source/_module.less | 64 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml b/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml index aa64e78aa234f..b2e0aaf20ce34 100644 --- a/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml +++ b/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml @@ -11,7 +11,9 @@ $viewFileUrl = $block->getViewFileUrl('Magento_LoginAsCustomerFrontendUi::images/magento-icon.svg'); ?> getConfig()->isEnabled()): ?> -
+