From b259f81099eb9fffdd1983e864d405661af153dc Mon Sep 17 00:00:00 2001 From: aplapana Date: Fri, 12 Jan 2024 15:15:26 +0200 Subject: [PATCH 01/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - grid list widget template now incorporates product options --- .../Block/Product/ProductsList.php | 22 ++++++++++++++++++- .../product/widget/content/grid.phtml | 6 +++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php index 4ca4bc1e2dc7..38cb2bff75ec 100644 --- a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php +++ b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php @@ -15,6 +15,7 @@ use Magento\Catalog\Model\ResourceModel\Product\Collection; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\Catalog\Pricing\Price\FinalPrice; +use Magento\Catalog\ViewModel\Product\OptionsData; use Magento\CatalogWidget\Model\Rule; use Magento\Framework\App\ActionInterface; use Magento\Framework\App\Http\Context as HttpContext; @@ -130,6 +131,11 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn */ private $categoryRepository; + /** + * @var OptionsData + */ + private OptionsData $optionsData; + /** * @param Context $context * @param CollectionFactory $productCollectionFactory @@ -143,6 +149,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn * @param LayoutFactory|null $layoutFactory * @param EncoderInterface|null $urlEncoder * @param CategoryRepositoryInterface|null $categoryRepository + * @param OptionsData|null $optionsData * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -158,7 +165,8 @@ public function __construct( Json $json = null, LayoutFactory $layoutFactory = null, EncoderInterface $urlEncoder = null, - CategoryRepositoryInterface $categoryRepository = null + CategoryRepositoryInterface $categoryRepository = null, + OptionsData $optionsData = null ) { $this->productCollectionFactory = $productCollectionFactory; $this->catalogProductVisibility = $catalogProductVisibility; @@ -171,6 +179,7 @@ public function __construct( $this->urlEncoder = $urlEncoder ?: ObjectManager::getInstance()->get(EncoderInterface::class); $this->categoryRepository = $categoryRepository ?? ObjectManager::getInstance() ->get(CategoryRepositoryInterface::class); + $this->optionsData = $optionsData ?: ObjectManager::getInstance()->get(OptionsData::class); parent::__construct( $context, $data @@ -306,6 +315,17 @@ public function getAddToCartPostParams(Product $product) ]; } + /** + * Return product options + * + * @param Product $product + * @return array + */ + public function getOptionsData(Product $product): array + { + return $this->optionsData->getOptionsData($product); + } + /** * @inheritdoc */ diff --git a/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml b/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml index 78797f295c13..8e593632f754 100644 --- a/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml +++ b/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml @@ -74,6 +74,12 @@ use Magento\Wishlist\Helper\Data; isSaleable()): ?> getAddToCartPostParams($_item); ?>
+ getOptionsData($_item); ?> + + + getBlockHtml('formkey') ?> From 17226f3ac5ad27f4a6e4254cb9c41f0567337924 Mon Sep 17 00:00:00 2001 From: aplapana Date: Fri, 19 Jan 2024 14:09:51 +0200 Subject: [PATCH 02/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - added MFTF test --- .../StorefrontBundleAddToCartFromWidget.xml | 73 +++++++++++++++++++ ...atalogProductsListWidgetSkuActionGroup.xml | 30 ++++++++ 2 files changed, 103 insertions(+) create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml create mode 100644 app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml new file mode 100644 index 000000000000..778003e2e437 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml @@ -0,0 +1,73 @@ + + + + + + + + + + <description value="Customer should be able to add a bundle product to the cart from widget"/> + <severity value="CRITICAL"/> + <testCaseId value="AC-10867"/> + <group value="Bundle"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> + <createData entity="SimpleProduct2" stepKey="simpleProduct1"/> + </before> + <after> + <actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteBundleProductBySku"> + <argument name="sku" value="{{BundleProductWithSlashSku.sku}}"/> + </actionGroup> + <deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <!-- Start creating a bundle product --> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="goToProductList"/> + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct"> + <argument name="product" value="BundleProduct"/> + </actionGroup> + <actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillNameAndSku"> + <argument name="product" value="BundleProductWithSlashSku"/> + </actionGroup> + + <!-- Add Option One, a "Drop-down" type option --> + <actionGroup ref="AddBundleOptionWithOneProductActionGroup" stepKey="addBundleOptionWithOneProduct"> + <argument name="x" value="0"/> + <argument name="n" value="1"/> + <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> + <argument name="prodTwoSku" value=""/> + <argument name="optionTitle" value="Option One"/> + <argument name="inputType" value="select"/> + </actionGroup> + + <!-- Save product, edit Homepage CMS page and add products widget --> + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> + <amOnPage url="{{AdminCmsPageEditPage.url(CmsHomePageContent.page_id)}}" stepKey="navigateToEditCmsHomePage"/> + <click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickContentTab" /> + <actionGroup ref="AdminInsertWidgetToCmsPageContentActionGroup" stepKey="insertWidgetToCmsPageContentActionGroup"> + <argument name="widgetType" value="Catalog Products List"/> + </actionGroup> + <actionGroup ref="AdminFillCatalogProductsListWidgetSkuActionGroup" stepKey="selectProductForListing"> + <argument name="sku" value="{{BundleProductWithSlashSku.sku}}"/> + </actionGroup> + <actionGroup ref="AdminClickInsertWidgetActionGroup" stepKey="clickInsertWidgetButton2"/> + <actionGroup ref="SaveCmsPageActionGroup" stepKey="clickSaveButton"/> + <see selector="{{AdminMessagesSection.success}}" userInput="You saved the page." stepKey="seeSuccess"/> + + <!-- Go to storefront homepage and add to cart --> + <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/> + <actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverProduct"/> + <actionGroup ref="StorefrontClickAddToCartButtonActionGroup" stepKey="addToCart"/> + <waitForPageLoad stepKey="waitForProductAdded"/> + <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="seeSuccessMessage"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml b/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml new file mode 100644 index 000000000000..65ecfdaa4cce --- /dev/null +++ b/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminFillCatalogProductsListWidgetSkuActionGroup"> + <annotations> + <description>Fill catalog products list widget sku.</description> + </annotations> + + <arguments> + <argument name="sku" type="string" defaultValue=""/> + </arguments> + + <waitForElementVisible selector="{{WidgetSection.AddParam}}" stepKey="waitForAddParamElement"/> + <click selector="{{WidgetSection.AddParam}}" stepKey="clickOnAddParamElement"/> + <waitForElementVisible selector="{{WidgetSection.ConditionsDropdown}}" + stepKey="waitForConditionsDropdownVisible"/> + <selectOption selector="{{WidgetSection.ConditionsDropdown}}" userInput="SKU" stepKey="selectSkuAsCondition"/> + <waitForElementVisible selector="{{WidgetSection.RuleParam}}" stepKey="waitForRuleParamElementVisible"/> + <click selector="{{WidgetSection.RuleParam}}" stepKey="clickToAddRuleParam"/> + <fillField selector=".rule-param-edit input" userInput="{{sku}}" stepKey="fillSkuField"/> + <click selector="{{AdminNewWidgetSection.applyParameter}}" stepKey="clickApplyButton"/> + </actionGroup> +</actionGroups> From 58e47532117b148c2275c1133d51f84382a50e32 Mon Sep 17 00:00:00 2001 From: aplapana <aplapana@adobe.com> Date: Fri, 19 Jan 2024 14:57:03 +0200 Subject: [PATCH 03/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - added soft dependency --- app/code/Magento/Bundle/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 79ec483d4dd6..9b345b8d4d42 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -27,7 +27,8 @@ "suggest": { "magento/module-webapi": "*", "magento/module-bundle-sample-data": "*", - "magento/module-sales-rule": "*" + "magento/module-sales-rule": "*", + "magento/module-catalog-widget": "*" }, "type": "magento2-module", "license": [ From 685aa4bcd92a4ea55a6cba88757257cc235d8310 Mon Sep 17 00:00:00 2001 From: aplapana <aplapana@adobe.com> Date: Mon, 22 Jan 2024 10:30:59 +0200 Subject: [PATCH 04/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - removed soft dependency --- .../AdminFillCatalogProductsListWidgetSkuActionGroup.xml | 0 app/code/Magento/Bundle/composer.json | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) rename app/code/Magento/{CatalogWidget => Bundle}/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml (100%) diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml b/app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml similarity index 100% rename from app/code/Magento/CatalogWidget/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml rename to app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml diff --git a/app/code/Magento/Bundle/composer.json b/app/code/Magento/Bundle/composer.json index 9b345b8d4d42..79ec483d4dd6 100644 --- a/app/code/Magento/Bundle/composer.json +++ b/app/code/Magento/Bundle/composer.json @@ -27,8 +27,7 @@ "suggest": { "magento/module-webapi": "*", "magento/module-bundle-sample-data": "*", - "magento/module-sales-rule": "*", - "magento/module-catalog-widget": "*" + "magento/module-sales-rule": "*" }, "type": "magento2-module", "license": [ From ef0cee26cbe325ee0457b136057d6c2b976905f3 Mon Sep 17 00:00:00 2001 From: aplapana <aplapana@adobe.com> Date: Mon, 22 Jan 2024 15:12:21 +0200 Subject: [PATCH 05/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - test should be executed without WYSIWYG editor --- .../Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml index 778003e2e437..4e00d253850f 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml @@ -16,6 +16,7 @@ <description value="Customer should be able to add a bundle product to the cart from widget"/> <severity value="CRITICAL"/> <testCaseId value="AC-10867"/> + <group value="WYSIWYGDisabled"/> <group value="Bundle"/> </annotations> <before> From 715d15f773e8a228202f4bdb73ea4488daa35685 Mon Sep 17 00:00:00 2001 From: aplapana <aplapana@adobe.com> Date: Mon, 22 Jan 2024 18:35:16 +0200 Subject: [PATCH 06/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - adjusted copyright --- ...atalogProductsListWidgetSkuActionGroup.xml | 19 +++++++++++++++---- .../StorefrontBundleAddToCartFromWidget.xml | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml b/app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml index 65ecfdaa4cce..1b5add1d3880 100644 --- a/app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml +++ b/app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminFillCatalogProductsListWidgetSkuActionGroup.xml @@ -1,9 +1,20 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ +/************************************************************************ + * + * Copyright 2023 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + * *********************************************************************** + */ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml index 4e00d253850f..2da5732133f7 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml @@ -1,9 +1,20 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ +/************************************************************************ + * + * Copyright 2023 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + * *********************************************************************** + */ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" From 70d89adb73bc1692b8dadad0e387d1034f525fcf Mon Sep 17 00:00:00 2001 From: aplapana <aplapana@adobe.com> Date: Tue, 23 Jan 2024 09:09:56 +0200 Subject: [PATCH 07/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - added use case id for mftf test --- .../Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml index 2da5732133f7..5025ff1a659f 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartFromWidget.xml @@ -27,6 +27,7 @@ <description value="Customer should be able to add a bundle product to the cart from widget"/> <severity value="CRITICAL"/> <testCaseId value="AC-10867"/> + <useCaseId value="ACP2E-2615"/> <group value="WYSIWYGDisabled"/> <group value="Bundle"/> </annotations> From 4a4ef64ed0ae3943db48a64d0df4327aa79bffd9 Mon Sep 17 00:00:00 2001 From: aplapana <aplapana@adobe.com> Date: Tue, 27 Feb 2024 09:59:37 +0200 Subject: [PATCH 08/12] ACP2E-2615: Bundle products added via the Page Builder > Products widget break the cart - addressed static issue --- .../view/frontend/templates/product/widget/content/grid.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml b/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml index 8e593632f754..ed12241d6231 100644 --- a/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml +++ b/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml @@ -113,13 +113,13 @@ use Magento\Wishlist\Helper\Data; <div class="actions-secondary" data-role="add-to-links"> <?php if ($this->helper(Data::class)->isAllow() && $showWishlist): ?> <a href="#" - data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"> + data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $escaper->escapeHtmlAttr(__('Add to Wish List')) ?>"> <span><?= $escaper->escapeHtml(__('Add to Wish List')) ?></span> </a> <?php endif; ?> <?php if ($block->getAddToCompareUrl() && $showCompare): ?> <?php $compareHelper = $this->helper(Compare::class);?> - <a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>"> + <a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $escaper->escapeHtmlAttr(__('Add to Compare')) ?>"> <span><?= $escaper->escapeHtml(__('Add to Compare')) ?></span> </a> <?php endif; ?> From 88688710293bdec3de9bdc19df2419ce1ee7c7b4 Mon Sep 17 00:00:00 2001 From: Oleksandr Dubovyk <odubovyk@adobe.com> Date: Fri, 1 Mar 2024 09:24:19 -0600 Subject: [PATCH 09/12] ACP2E-2711: Error message is displayed during setup:upgrade when the database contains a custom MySQL trigger which is not related to the indexation mechanism --- .../Mview/Test/Unit/TriggerCleanerTest.php | 56 +++++++++++++++++++ .../Framework/Mview/TriggerCleaner.php | 6 +- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/TriggerCleanerTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/TriggerCleanerTest.php index 556cc4b602c9..7fad394b38a0 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/TriggerCleanerTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/TriggerCleanerTest.php @@ -117,6 +117,62 @@ public function testRemoveTriggersNoChanges(): void $this->model->removeTriggers(); } + public function testRemoveTriggersNotLinked(): void + { + $DBTriggers = [ + 'trg_catalog_category_entity_int_after_insert' => [ + 'TRIGGER_NAME' => 'trg_catalog_category_entity_int_after_insert', + 'ACTION_STATEMENT' => 'BEGIN statement; END', + 'EVENT_OBJECT_TABLE' => 'catalog_category_entity_int' + ], + 'not_linked_trg_catalog_category_entity_int_after_insert' => [ + 'TRIGGER_NAME' => 'trg_catalog_category_entity_int_after_insert', + 'ACTION_STATEMENT' => 'BEGIN statement; END', + 'EVENT_OBJECT_TABLE' => 'catalog_category_entity_int' + ] + ]; + + $connectionMock = $this->getConnectionMock(); + $connectionMock->expects($this->once()) + ->method('fetchAssoc') + ->willReturn($DBTriggers); + + $this->resource->expects($this->once())->method('getConnection')->willReturn($connectionMock); + + $triggerMock = $this->getMockBuilder(Trigger::class) + ->disableOriginalConstructor() + ->onlyMethods(['getName', 'getStatements']) + ->getMockForAbstractClass(); + $triggerMock->expects($this->atLeastOnce()) + ->method('getName') + ->willReturn('trg_catalog_category_entity_int_after_insert'); + $triggerMock->expects($this->once())->method('getStatements')->willReturn(['statement;']); + + $subscriptionMock = $this->createMock(Subscription::class); + $subscriptionMock->expects($this->once())->method('getTriggers')->willReturn([$triggerMock]); + $subscriptionMock->expects($this->once())->method('create')->willReturn($subscriptionMock); + + $viewMock = $this->createMock(View::class); + $viewMock->expects($this->once()) + ->method('getSubscriptions') + ->willReturn(['subscriptionConfig' => []]); + $viewMock->expects($this->once())->method('initSubscriptionInstance')->willReturn($subscriptionMock); + + $viewCollectionMock = $this->getMockForAbstractClass(CollectionInterface::class); + $viewCollectionMock->expects($this->once())->method('getViewsByStateMode')->willReturn([$viewMock]); + + $this->viewCollectionFactory->expects($this->once())->method('create')->willReturn($viewCollectionMock); + + $subscriptionMock->expects($this->never())->method('saveTrigger'); + $viewMock->expects($this->once())->method('unsubscribe'); + + $this->viewFactory->expects($this->once())->method('create')->willReturn($viewMock); + $state = $this->createMock(\Magento\Indexer\Model\Mview\View\State::class); + $viewMock->expects($this->once())->method('getActionClass')->willReturn(true); + $viewMock->expects($this->exactly(2))->method('getState')->willReturn($state); + $this->model->removeTriggers(); + } + /** * Prepare connection mock * diff --git a/lib/internal/Magento/Framework/Mview/TriggerCleaner.php b/lib/internal/Magento/Framework/Mview/TriggerCleaner.php index 81ccf9a4991a..aba8d5fd407f 100644 --- a/lib/internal/Magento/Framework/Mview/TriggerCleaner.php +++ b/lib/internal/Magento/Framework/Mview/TriggerCleaner.php @@ -87,8 +87,10 @@ public function removeTriggers(): bool $remainingTriggers = array_diff_key($this->DbTriggers, $this->processedTriggers); foreach ($remainingTriggers as $trigger) { $view = $this->createViewByTableName($trigger['EVENT_OBJECT_TABLE']); - $view->unsubscribe(); - $view->getState()->delete(); + if ($view->getActionClass()) { + $view->unsubscribe(); + $view->getState()->delete(); + } } return true; From 649d2fd2edd5038bdea41f20b491216d7069d16d Mon Sep 17 00:00:00 2001 From: vkolesny <vkolesny@adobe.com> Date: Wed, 5 Jun 2024 08:58:17 -0500 Subject: [PATCH 10/12] ACP2E-3032: [Documentation] Please mention that POST "ship" REST API call does not validate total shipped items quantity. --- app/code/Magento/Sales/Api/Data/ShipmentInterface.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php index ef7771c92203..da2f3e491bc6 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php @@ -9,7 +9,9 @@ * Shipment interface. * * A shipment is a delivery package that contains products. A shipment document accompanies the shipment. This - * document lists the products and their quantities in the delivery package. + * document lists the products and their quantities in the delivery package. This interface creates shipment + * record without items quantity (total_qty) validation. To validate total shipped quantity for each item + * in the order you must use newer `POST /V1/order/:orderId/ship` endpoint. * @api * @since 100.0.2 */ @@ -31,7 +33,7 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa */ const TOTAL_WEIGHT = 'total_weight'; /* - * Total quantity. + * Total quantity. Can be greater than ordered (not validated). */ const TOTAL_QTY = 'total_qty'; /* From b036984e7c78d5cee9c8c37a2e40c16e00188b96 Mon Sep 17 00:00:00 2001 From: vkolesny <vkolesny@adobe.com> Date: Thu, 6 Jun 2024 09:41:35 -0500 Subject: [PATCH 11/12] ACP2E-3032: [Documentation] Please mention that POST "ship" REST API call does not validate total shipped items quantity. --- app/code/Magento/Sales/Api/Data/ShipmentInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php index da2f3e491bc6..85312cd5dfa4 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php @@ -33,7 +33,7 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa */ const TOTAL_WEIGHT = 'total_weight'; /* - * Total quantity. Can be greater than ordered (not validated). + * Total quantity. Can be greater than ordered quantity (not validated). */ const TOTAL_QTY = 'total_qty'; /* From 9f323df8577bc06b84c5888b9d755faa29ee3280 Mon Sep 17 00:00:00 2001 From: Oleksandr Dubovyk <odubovyk@adobe.com> Date: Fri, 5 Jul 2024 15:37:30 -0500 Subject: [PATCH 12/12] ACP2E-3032: [Documentation] Please mention that POST "ship" REST API call does not validate total shipped items quantity. --- .../Sales/Api/Data/ShipmentInterface.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php index 85312cd5dfa4..2f9f03c79f62 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php @@ -23,75 +23,75 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa /* * Entity ID. */ - const ENTITY_ID = 'entity_id'; + public const ENTITY_ID = 'entity_id'; /* * Store ID. */ - const STORE_ID = 'store_id'; + public const STORE_ID = 'store_id'; /* * Total weight. */ - const TOTAL_WEIGHT = 'total_weight'; + public const TOTAL_WEIGHT = 'total_weight'; /* * Total quantity. Can be greater than ordered quantity (not validated). */ - const TOTAL_QTY = 'total_qty'; + public const TOTAL_QTY = 'total_qty'; /* * Email sent flag. */ - const EMAIL_SENT = 'email_sent'; + public const EMAIL_SENT = 'email_sent'; /* * Order ID. */ - const ORDER_ID = 'order_id'; + public const ORDER_ID = 'order_id'; /* * Customer ID. */ - const CUSTOMER_ID = 'customer_id'; + public const CUSTOMER_ID = 'customer_id'; /* * Shipping address ID. */ - const SHIPPING_ADDRESS_ID = 'shipping_address_id'; + public const SHIPPING_ADDRESS_ID = 'shipping_address_id'; /* * Billing address ID. */ - const BILLING_ADDRESS_ID = 'billing_address_id'; + public const BILLING_ADDRESS_ID = 'billing_address_id'; /* * Shipment status. */ - const SHIPMENT_STATUS = 'shipment_status'; + public const SHIPMENT_STATUS = 'shipment_status'; /* * Increment ID. */ - const INCREMENT_ID = 'increment_id'; + public const INCREMENT_ID = 'increment_id'; /* * Created-at timestamp. */ - const CREATED_AT = 'created_at'; + public const CREATED_AT = 'created_at'; /* * Updated-at timestamp. */ - const UPDATED_AT = 'updated_at'; + public const UPDATED_AT = 'updated_at'; /* * Packages. */ - const PACKAGES = 'packages'; + public const PACKAGES = 'packages'; /* * Shipping label. */ - const SHIPPING_LABEL = 'shipping_label'; + public const SHIPPING_LABEL = 'shipping_label'; /* * Items. */ - const ITEMS = 'items'; + public const ITEMS = 'items'; /* * Tracks. */ - const TRACKS = 'tracks'; + public const TRACKS = 'tracks'; /* * Comments. */ - const COMMENTS = 'comments'; + public const COMMENTS = 'comments'; /** * Gets the billing address ID for the shipment.