From 68170c1a4a7b8b849e3a19d40ffe37ae3ae06292 Mon Sep 17 00:00:00 2001 From: OlgaVasyltsun Date: Wed, 8 Jan 2020 14:10:37 +0200 Subject: [PATCH 01/12] MC-23870: Error messages on Checkout when 'Syncronize with Backend' option is turned ON --- .../ProductFrontendAction/Synchronizer.php | 31 +++-- .../Catalog/view/frontend/layout/default.xml | 3 + .../SynchronizerTest.php | 106 ++++++++++++++++++ 3 files changed, 129 insertions(+), 11 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductFrontendAction/SynchronizerTest.php diff --git a/app/code/Magento/Catalog/Model/Product/ProductFrontendAction/Synchronizer.php b/app/code/Magento/Catalog/Model/Product/ProductFrontendAction/Synchronizer.php index 24775a791e59f..ec2e697ccc849 100644 --- a/app/code/Magento/Catalog/Model/Product/ProductFrontendAction/Synchronizer.php +++ b/app/code/Magento/Catalog/Model/Product/ProductFrontendAction/Synchronizer.php @@ -125,9 +125,16 @@ private function filterNewestActions(array $productsData, $typeId) $lifetime = $this->getLifeTimeByNamespace($typeId); $actionsNumber = $lifetime * self::TIME_TO_DO_ONE_ACTION; - uasort($productsData, function (array $firstProduct, array $secondProduct) { - return $firstProduct['added_at'] > $secondProduct['added_at']; - }); + uasort( + $productsData, + function (array $firstProduct, array $secondProduct) { + if (isset($firstProduct['added_at'], $secondProduct['added_at'])) { + return $firstProduct['added_at'] > $secondProduct['added_at']; + } + + return false; + } + ); return array_slice($productsData, 0, $actionsNumber, true); } @@ -185,15 +192,17 @@ public function syncActions(array $productsData, $typeId) foreach ($productsData as $productId => $productData) { /** @var ProductFrontendActionInterface $action */ - $action = $this->productFrontendActionFactory->create([ - 'data' => [ - 'visitor_id' => $customerId ? null : $visitorId, - 'customer_id' => $this->session->getCustomerId(), - 'added_at' => $productData['added_at'], - 'product_id' => $productId, - 'type_id' => $typeId + $action = $this->productFrontendActionFactory->create( + [ + 'data' => [ + 'visitor_id' => $customerId ? null : $visitorId, + 'customer_id' => $this->session->getCustomerId(), + 'added_at' => $productData['added_at'], + 'product_id' => $productId, + 'type_id' => $typeId + ] ] - ]); + ); $this->entityManager->save($action); } diff --git a/app/code/Magento/Catalog/view/frontend/layout/default.xml b/app/code/Magento/Catalog/view/frontend/layout/default.xml index 3dff3e9b3c1f8..8f414724f51db 100644 --- a/app/code/Magento/Catalog/view/frontend/layout/default.xml +++ b/app/code/Magento/Catalog/view/frontend/layout/default.xml @@ -26,6 +26,9 @@ + + + diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductFrontendAction/SynchronizerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductFrontendAction/SynchronizerTest.php new file mode 100644 index 0000000000000..3ea30005e9f6c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/ProductFrontendAction/SynchronizerTest.php @@ -0,0 +1,106 @@ +synchronizer = $objectManager->get(Synchronizer::class); + $this->productRepository = $objectManager->get(ProductRepository::class); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php + * + * @return void + */ + public function testSyncActions(): void + { + $actionsType = 'recently_viewed_product'; + $product1 = $this->productRepository->get('simple'); + $product2 = $this->productRepository->get('simple2'); + $product1Id = $product1->getId(); + $product2Id = $product2->getId(); + $productsData = [ + $product1Id => [ + 'added_at' => '1576582660', + 'product_id' => $product1Id, + ], + $product2Id => [ + 'added_at' => '1576587153', + 'product_id' => $product2Id, + ], + ]; + + $this->synchronizer->syncActions($productsData, $actionsType); + + $synchronizedCollection = $this->synchronizer->getActionsByType($actionsType); + $synchronizedCollection->addFieldToFilter( + 'product_id', + [ + $product1Id, + $product2Id, + ] + ); + + foreach ($synchronizedCollection as $item) { + $this->assertArrayHasKey($item->getProductId(), $productsData); + $this->assertEquals($productsData[$item->getProductId()]['added_at'], $item->getAddedAt()); + } + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php + * + * @return void + */ + public function testSyncActionsWithoutActionsType(): void + { + $product1 = $this->productRepository->get('simple'); + $product2 = $this->productRepository->get('simple2'); + $product1Id = $product1->getId(); + $product2Id = $product2->getId(); + $productsData = [ + $product1Id => [ + 'id' => $product1Id, + 'name' => $product1->getName(), + 'type' => $product1->getTypeId(), + ], + $product2Id => [ + 'id' => $product2Id, + 'name' => $product2->getName(), + 'type' => $product2->getTypeId(), + ], + ]; + + $this->synchronizer->syncActions($productsData, ''); + } +} From 7633af187af63892ce58ed89b199a9bbf7e8a590 Mon Sep 17 00:00:00 2001 From: OlgaVasyltsun Date: Mon, 20 Jan 2020 09:52:51 +0200 Subject: [PATCH 02/12] MC-30398: Filter are not present on category page --- .../Data/UpdateDefaultAttributeValue.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php index 1d58de1994a11..e658d837efbaf 100644 --- a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php +++ b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php @@ -3,19 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Catalog\Setup\Patch\Data; use Magento\Catalog\Setup\CategorySetup; use Magento\Catalog\Setup\CategorySetupFactory; -use Magento\Framework\App\ResourceConnection; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\Patch\DataPatchInterface; use Magento\Framework\Setup\Patch\PatchVersionInterface; /** - * Class UpdateDefaultAttributeValue - * @package Magento\Catalog\Setup\Patch + * Updates 'is_anchor' attribute default value. */ class UpdateDefaultAttributeValue implements DataPatchInterface, PatchVersionInterface { @@ -30,7 +29,6 @@ class UpdateDefaultAttributeValue implements DataPatchInterface, PatchVersionInt private $categorySetupFactory; /** - * PatchInitial constructor. * @param ModuleDataSetupInterface $moduleDataSetup * @param CategorySetupFactory $categorySetupFactory */ @@ -43,17 +41,22 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function apply() { /** @var CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]); - $categorySetup->updateAttribute(3, 54, 'default_value', 1); + $categorySetup->updateAttribute( + CategorySetup::CATEGORY_ENTITY_TYPE_ID, + 'is_anchor', + 'default_value', + 1 + ); } /** - * {@inheritdoc} + * @inheritdoc */ public static function getDependencies() { @@ -63,7 +66,7 @@ public static function getDependencies() } /** - * {@inheritdoc} + * @inheritdoc */ public static function getVersion() { @@ -71,7 +74,7 @@ public static function getVersion() } /** - * {@inheritdoc} + * @inheritdoc */ public function getAliases() { From 914bae6e0f1fefb974c47694aba0032ad9d3e2a2 Mon Sep 17 00:00:00 2001 From: OlgaVasyltsun Date: Mon, 20 Jan 2020 10:44:06 +0200 Subject: [PATCH 03/12] MC-30398: Filter are not present on category page --- .../Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php index e658d837efbaf..4500d86ad4a6c 100644 --- a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php +++ b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateDefaultAttributeValue.php @@ -53,6 +53,8 @@ public function apply() 'default_value', 1 ); + + return $this; } /** From 093e30600f58f506a3dc5e853b8b3c4b205157f4 Mon Sep 17 00:00:00 2001 From: Viktor Petryk Date: Mon, 20 Jan 2020 17:16:30 +0200 Subject: [PATCH 04/12] MC-24906: An error notification is displayed while creating return on storefront --- .../shipment_for_order_with_customer.php | 27 +++++++++++++++++++ ...pment_for_order_with_customer_rollback.php | 8 ++++++ 2 files changed, 35 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer.php b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer.php new file mode 100644 index 0000000000000..c5304f5b8809f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer.php @@ -0,0 +1,27 @@ +setIsInProcess(true); +/** @var Transaction $transaction */ +$transaction = $objectManager->create(Transaction::class); + +$items = []; +foreach ($order->getItems() as $orderItem) { + $items[$orderItem->getId()] = $orderItem->getQtyOrdered(); +} + +$shipment = $objectManager->get(ShipmentFactory::class)->create($order, $items); +$shipment->register(); + +$transaction->addObject($shipment)->addObject($order)->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer_rollback.php new file mode 100644 index 0000000000000..2595d6bf4084a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/shipment_for_order_with_customer_rollback.php @@ -0,0 +1,8 @@ + Date: Fri, 24 Jan 2020 14:44:43 +0200 Subject: [PATCH 05/12] MC-23753: "<" and ">" symbols are changed to "<" and ">" in the frontend catalog search line --- .../Magento/Search/view/frontend/templates/form.mini.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Search/view/frontend/templates/form.mini.phtml b/app/code/Magento/Search/view/frontend/templates/form.mini.phtml index 0dd9c819c855a..35f3876599731 100644 --- a/app/code/Magento/Search/view/frontend/templates/form.mini.phtml +++ b/app/code/Magento/Search/view/frontend/templates/form.mini.phtml @@ -14,7 +14,8 @@ $helper = $this->helper(\Magento\Search\Helper\Data::class);