Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.4-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #32187: [Sales] Fixed order address retriever for prevent populating data from shipping to billing (by @Den4ik)
 - #32082: Deleting disabled category forces category flat and catalog search re-indexed fully (by @engcom-Charlie)
 - #31851: Removed CliIndexerReindexActionGroup action group usage for modules (mix) (by @sergiy-v)
 - #32078: Removed CliCacheFlushActionGroup usage for Customer module (by @sergiy-v)
 - #31933: Do not send an ajax request if there no affected sections (by @ihor-sviziev)
 - #32009: REST API Product update url_key doesnt re-gerenate url_rewites when single store enabled (by @engcom-Charlie)
 - #31953: Removed CliCacheFlushActionGroup usage for ConfigurableProduct module (by @sergiy-v)
 - #31886: Fix #30471 - Page layouts are hard-coded in Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container (by @Bartlomiejsz)
 - #30850: [MFTF] Refactoring of AdminConfigDefaultProductLayoutFromConfigurationSettingTest (by @AnnaAPak)
 - #30329: Resolve Login As Customer Log - Logged In must be DateRange Filter instead of Text filter, Date display wrong timezone issue30328 (by @edenduong)
 - #31395: [MFTF] Refactoring AdminCreateCreditMemoForOrderWithCashOnDeliveryTest (by @AnnaAPak)
 - #31390: [MFTF] Coverage for the 30645 Customer Edit Issue when there is a newsletter queue associated with it  (by @AnnaAPak)
 - #31645: Adding required custom options to simple product removes it from parent composite products without warning (by @engcom-Charlie)
 - #32249: Magento_Backend store switcher: Use nowdoc instead of heredoc (by @fnogatz)
 - #32299: Move test to correct folder (by @ihor-sviziev)
 - #31451: [MFTF] Refactoring AdminCheckDashboardWithChartsTest (by @AnnaAPak)
 - #31482: show or hide password widget created (by @ajithkumar-maragathavel)


Fixed GitHub Issues:
 - #31608: Shipping address region leaking into billing address (reported by @kassner) has been fixed in #32187 by @Den4ik in 2.4-develop branch
   Related commits:
     1. bc33796
     2. 94b34b9
     3. dc5ecb8
     4. b066cea
     5. 02a792f
     6. ce458ae
     7. 9d9104e
     8. a377151
     9. d78e9f8
     10. 67ab661
     11. 2bcdb1e

 - #23297: Deleting disabled category forces category flat and catalog search re-indexed fully (reported by @gulshan-streammarket) has been fixed in #32082 by @engcom-Charlie in 2.4-develop branch
   Related commits:
     1. 3d52a3b
     2. 8b0f561
     3. 0d4d04b
     4. 409ccc6
     5. 11494b2
     6. 882e719
     7. 44bc26f
     8. 977be92
     9. 722cf47
     10. 68c7282
     11. 849db8c
     12. 0930cf5

 - #31852: [Issue] Removed CliIndexerReindexActionGroup action group usage for modules (mix) (reported by @m2-assistant[bot]) has been fixed in #31851 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. 4cfff44

 - #32079: [Issue] Removed CliCacheFlushActionGroup usage for Customer module (reported by @m2-assistant[bot]) has been fixed in #32078 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. dbdb3e2

 - #31948: [Issue] Do not send an ajax request if there no affected sections (reported by @m2-assistant[bot]) has been fixed in #31933 by @ihor-sviziev in 2.4-develop branch
   Related commits:
     1. 24dfb62
     2. 4314fd9
     3. c98919b
     4. d95ba9c
     5. 5728c0b
     6. c63f878

 - #30316: REST API Product update url_key doesnt re-gerenate url_rewites (INSANE) (reported by @Seb2nim) has been fixed in #32009 by @engcom-Charlie in 2.4-develop branch
   Related commits:
     1. 494eb40
     2. 883f89b
     3. 35a1aa8
     4. 3644e17

 - #31954: [Issue] Removed CliCacheFlushActionGroup usage for ConfigurableProduct module (reported by @m2-assistant[bot]) has been fixed in #31953 by @sergiy-v in 2.4-develop branch
   Related commits:
     1. c6dad9d
     2. 4b85052
     3. 955f322

 - #30471: Page layouts are hard-coded in Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container (reported by @ericmorand) has been fixed in #31886 by @Bartlomiejsz in 2.4-develop branch
   Related commits:
     1. 1b9f190
     2. 2ea06fb
     3. db81b6b
     4. 23db47e

 - #30855: [Issue] [MFTF] Refactoring of AdminConfigDefaultProductLayoutFromConfigurationSettingTest (reported by @m2-assistant[bot]) has been fixed in #30850 by @AnnaAPak in 2.4-develop branch
   Related commits:
     1. c0728b8
     2. 625a01a
     3. 4772239
     4. a4bf8b3
     5. 283389b
     6. b5151b8
     7. 371e300
     8. be757be
     9. b8149af
     10. 0b0f118

 - #30328: Login As Customer Log - Logged In must be DateRange Filter instead of Text filter, Date display wrong timezone (reported by @edenduong) has been fixed in #30329 by @edenduong in 2.4-develop branch
   Related commits:
     1. eeb47dd
     2. b4f5784
     3. 85b410d
     4. 36472eb
     5. 312d9d4
     6. a16616b
     7. 8ddd329
     8. ef72f80
     9. d372d2b
     10. 3038e85
     11. c8fb47e
     12. 46aa750
     13. 60b8981
     14. a48886c
     15. 1afe3db
     16. 0fa2b89
     17. 60ebbba
     18. 6fb4052

 - #30645: Customer Edit Issue when there is a newsletter queue associated with it. (reported by @chichitsai0517) has been fixed in #31390 by @AnnaAPak in 2.4-develop branch
   Related commits:
     1. f26c89c
     2. ba66f05
     3. 7bf9886
     4. 0d745e1

 - #30492: Adding required custom options to simple product removes it from parent composite products without warning (reported by @magento2pl) has been fixed in #31645 by @engcom-Charlie in 2.4-develop branch
   Related commits:
     1. 86d30a5
     2. 2295da4
     3. 1b7697f

 - #32262: [Issue] Magento_Backend store switcher: Use nowdoc instead of heredoc (reported by @m2-assistant[bot]) has been fixed in #32249 by @fnogatz in 2.4-develop branch
   Related commits:
     1. c8a5013

 - #32313: [Issue] Move test to correct folder (reported by @m2-assistant[bot]) has been fixed in #32299 by @ihor-sviziev in 2.4-develop branch
   Related commits:
     1. 8f1b64e

 - #31523: [Issue] [MFTF] Refactoring AdminCheckDashboardWithChartsTest (reported by @m2-assistant[bot]) has been fixed in #31451 by @AnnaAPak in 2.4-develop branch
   Related commits:
     1. acefba2
     2. 7e0f55d
     3. 8af7b18
     4. 66e75fd
     5. b5ec75c
     6. 4b67412

 - #31557: [Issue] show or hide password widget created (reported by @m2-assistant[bot]) has been fixed in #31482 by @ajithkumar-maragathavel in 2.4-develop branch
   Related commits:
     1. 0dd3eeb
     2. 17d0dba
     3. 101aa44
     4. cd336ea
     5. 3f43759
     6. 832255f
     7. 1b2b513
     8. ed37763
     9. 541fa90
     10. 0fa58ee
     11. 9677540
     12. 1f7e5b5
     13. 7c0e401
     14. c816799
  • Loading branch information
gabrieldagama authored Mar 7, 2021
2 parents d1a2753 + 898da15 commit c364929
Show file tree
Hide file tree
Showing 128 changed files with 1,451 additions and 366 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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="AssertAdminDashboardDisplayedWithNoErrorsActionGroup">
<annotations>
<description>Checks if Dashboard is displayed properly</description>
</annotations>

<seeElement selector="{{AdminDashboardSection.dashboardDiagramOrderContentTab}}" stepKey="seeOrderContentTab"/>
<seeElement selector="{{AdminDashboardSection.dashboardDiagramContent}}" stepKey="seeDiagramContent"/>
<click selector="{{AdminDashboardSection.dashboardDiagramAmounts}}" stepKey="clickDashboardAmount"/>
<waitForLoadingMaskToDisappear stepKey="waitForDashboardAmountLoading"/>
<seeElement selector="{{AdminDashboardSection.dashboardDiagramAmountsContentTab}}" stepKey="seeDiagramAmountContent"/>
<seeElement selector="{{AdminDashboardSection.dashboardDiagramTotals}}" stepKey="seeAmountTotals"/>
<dontSeeJsError stepKey="dontSeeJsError"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminCheckDashboardWithChartsTest">
<annotations>
<features value="Backend"/>
<stories value="Google Charts on Magento dashboard"/>
<title value="Admin should see Google chart on Magento dashboard"/>
<description value="Google chart on Magento dashboard page is displaying properly"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-98934"/>
<useCaseId value="MAGETWO-98584"/>
<group value="backend"/>
</annotations>
<before>
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>
<createData entity="SimpleProduct2" stepKey="createProduct">
<field key="price">150</field>
</createData>
<createData entity="Simple_US_Customer" stepKey="createCustomer">
<field key="firstname">John1</field>
<field key="lastname">Doe1</field>
</createData>
<createData entity="CustomerCart" stepKey="createCustomerCart">
<requiredEntity createDataKey="createCustomer"/>
</createData>
<createData entity="CustomerCartItem" stepKey="addCartItem">
<requiredEntity createDataKey="createCustomerCart"/>
<requiredEntity createDataKey="createProduct"/>
</createData>
<createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress">
<requiredEntity createDataKey="createCustomerCart"/>
</createData>
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<magentoCLI command="config:set admin/dashboard/enable_charts 0" stepKey="setDisableChartsAsDefault"/>
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>

<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityBefore"/>

<updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformation">
<requiredEntity createDataKey="createCustomerCart"/>
</updateData>
<createData entity="Invoice" stepKey="invoiceOrder">
<requiredEntity createDataKey="createCustomerCart"/>
</createData>
<createData entity="Shipment" stepKey="shipOrder">
<requiredEntity createDataKey="createCustomerCart"/>
</createData>

<reloadPage stepKey="refreshPage"/>
<actionGroup ref="AssertAdminDashboardDisplayedWithNoErrorsActionGroup" stepKey="assertAdminDashboardNotBroken"/>
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityAfter"/>
<assertGreaterThan stepKey="checkQuantityWasChanged">
<actualResult type="const">$grabQuantityAfter</actualResult>
<expectedResult type="const">$grabQuantityBefore</expectedResult>
</assertGreaterThan>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminDashboardWithChartsTest">
<test name="AdminDashboardWithChartsTest" deprecated="Use AdminCheckDashboardWithChartsTest instead">
<annotations>
<features value="Backend"/>
<stories value="Google Charts on Magento dashboard"/>
<title value="Admin should see Google chart on Magento dashboard"/>
<title value="DEPRECATED. Admin should see Google chart on Magento dashboard"/>
<description value="Google chart on Magento dashboard page is displaying properly"/>
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-98934"/>
<useCaseId value="MAGETWO-98584"/>
<group value="backend"/>
<skip>
<issueId value="DEPRECATED">Use AdminCheckDashboardWithChartsTest instead</issueId>
</skip>
</annotations>
<before>
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ script;
setLocation(url);
';
} else {
$scriptString .= <<<script
$scriptString .= <<<'script'
jQuery('#preview_selected_store').val(scopeId);
jQuery('#preview_form').submit();
Expand Down
5 changes: 4 additions & 1 deletion app/code/Magento/Catalog/Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,10 @@ public function reindex()
*/
public function afterDeleteCommit()
{
$this->reindex();
if ($this->getIsActive() || $this->getDeletedChildrenIds()) {
$this->reindex();
}

return parent::afterDeleteCommit();
}

Expand Down
3 changes: 0 additions & 3 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,6 @@ public function getStoreIds()
if (!$this->hasStoreIds()) {
$storeIds = [];
if ($websiteIds = $this->getWebsiteIds()) {
if (!$this->isObjectNew() && $this->_storeManager->isSingleStoreMode()) {
$websiteIds = array_keys($websiteIds);
}
foreach ($websiteIds as $websiteId) {
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
$storeIds[] = $websiteStores;
Expand Down
68 changes: 58 additions & 10 deletions app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,55 @@

namespace Magento\Catalog\Model\Product\Option;

use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface as OptionRepository;
use Magento\Catalog\Model\Product\Option;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
use Magento\Catalog\Model\ResourceModel\Product\Relation;
use Magento\Framework\Exception\CouldNotSaveException;

/**
* Class SaveHandler
* SaveHandler for product option
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class SaveHandler implements ExtensionInterface
{
/**
* @var string[]
*/
private $compositeProductTypes = ['grouped', 'configurable', 'bundle'];

/**
* @var OptionRepository
*/
protected $optionRepository;

/**
* @var Relation
*/
private $relation;

/**
* @param OptionRepository $optionRepository
* @param Relation|null $relation
*/
public function __construct(
OptionRepository $optionRepository
OptionRepository $optionRepository,
?Relation $relation = null
) {
$this->optionRepository = $optionRepository;
$this->relation = $relation ?: ObjectManager::getInstance()->get(Relation::class);
}

/**
* Perform action on relation/extension attribute
*
* @param object $entity
* @param array $arguments
* @return \Magento\Catalog\Api\Data\ProductInterface|object
* @return ProductInterface|object
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute($entity, $arguments = [])
Expand All @@ -47,20 +68,19 @@ public function execute($entity, $arguments = [])
$optionIds = [];

if ($options) {
$optionIds = array_map(function ($option) {
/** @var \Magento\Catalog\Model\Product\Option $option */
$optionIds = array_map(function (Option $option) {
return $option->getOptionId();
}, $options);
}

/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
/** @var ProductInterface $entity */
foreach ($this->optionRepository->getProductOptions($entity) as $option) {
if (!in_array($option->getOptionId(), $optionIds)) {
$this->optionRepository->delete($option);
}
}
if ($options) {
$this->processOptionsSaving($options, (bool)$entity->dataHasChangedFor('sku'), (string)$entity->getSku());
$this->processOptionsSaving($options, (bool)$entity->dataHasChangedFor('sku'), $entity);
}

return $entity;
Expand All @@ -71,15 +91,43 @@ public function execute($entity, $arguments = [])
*
* @param array $options
* @param bool $hasChangedSku
* @param string $newSku
* @param ProductInterface $product
* @return void
* @throws CouldNotSaveException
*/
private function processOptionsSaving(array $options, bool $hasChangedSku, string $newSku)
private function processOptionsSaving(array $options, bool $hasChangedSku, ProductInterface $product): void
{
$isProductHasRelations = $this->isProductHasRelations($product);
/** @var ProductCustomOptionInterface $option */
foreach ($options as $option) {
if (!$isProductHasRelations && $option->getIsRequire()) {
$message = 'Required custom options cannot be added to a simple product'
. ' that is a part of a composite product.';
throw new CouldNotSaveException(__($message));
}

if ($hasChangedSku && $option->hasData('product_sku')) {
$option->setProductSku($newSku);
$option->setProductSku($product->getSku());
}
$this->optionRepository->save($option);
}
}

/**
* Check if product doesn't belong to composite product
*
* @param ProductInterface $product
* @return bool
*/
private function isProductHasRelations(ProductInterface $product): bool
{
$result = true;
if (!in_array($product->getId(), $this->compositeProductTypes)
&& $this->relation->getRelationsByChildren([$product->getId()])
) {
$result = false;
}

return $result;
}
}
5 changes: 4 additions & 1 deletion app/code/Magento/Catalog/Model/ResourceModel/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ protected function _beforeDelete(\Magento\Framework\DataObject $object)
*/
protected function _afterDelete(DataObject $object)
{
$this->indexerProcessor->markIndexerAsInvalid();
if ($object->getIsActive() || $object->getDeletedChildrenIds()) {
$this->indexerProcessor->markIndexerAsInvalid();
}

return parent::_afterDelete($object);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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="AdminExpandProductDesignSectionActionGroup">
<annotations>
<description>Expand the Design section on the Product Details page in Admin.</description>
</annotations>

<click selector="{{ProductDesignSection.DesignTab}}" stepKey="clickDesignTab"/>
<waitForPageLoad stepKey="waitForTabOpen"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* See COPYING.txt for license details.
*/
-->
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="AdminConfigDefaultProductLayoutFromConfigurationSettingTest">
<annotations>
<features value="Catalog"/>
Expand All @@ -21,18 +21,29 @@
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
</before>
<after>
<actionGroup ref="RestoreLayoutSetting" stepKey="sampleActionGroup"/>
<actionGroup ref="NavigateToDefaultLayoutsSettingActionGroup" stepKey="navigateToWebConfigurationPage1"/>
<actionGroup ref="AdminSetProductLayoutSettingsActionGroup" stepKey="sampleActionGroup">
<argument name="layout" value="1 column"/>
</actionGroup>
<actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCacheBeforeTestFinishes">
<argument name="tags" value="config"/>
</actionGroup>
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
</after>
<actionGroup ref="AdminOpenWebConfigurationPageActionGroup" stepKey="navigateToWebConfigurationPage"/>
<conditionalClick stepKey="expandDefaultLayouts" selector="{{WebSection.DefaultLayoutsTab}}" dependentSelector="{{WebSection.CheckIfTabExpand}}" visible="true"/>
<waitForElementVisible selector="{{DefaultLayoutsSection.productLayout}}" stepKey="DefaultProductLayout"/>
<selectOption selector="{{DefaultLayoutsSection.productLayout}}" userInput="3 columns" stepKey="select3ColumnsLayout"/>
<click selector="{{ContentManagementSection.Save}}" stepKey="clickSaveConfig"/>
<amOnPage url="{{AdminProductCreatePage.url(AddToDefaultSet.attributeSetId, 'simple')}}" stepKey="navigateToNewProduct"/>
<waitForPageLoad stepKey="wait1"/>
<click selector="{{ProductDesignSection.DesignTab}}" stepKey="clickOnDesignTab"/>
<waitForElementVisible selector="{{ProductDesignSection.LayoutDropdown}}" stepKey="waitForLayoutDropDown"/>

<actionGroup ref="NavigateToDefaultLayoutsSettingActionGroup" stepKey="navigateToWebConfigurationPage"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="expandDefaultLayouts"/>
<comment userInput="Comment is added to preserve the step key for backward compatibilityr" stepKey="DefaultProductLayout"/>
<actionGroup ref="AdminSetProductLayoutSettingsActionGroup" stepKey="select3ColumnsLayout">
<argument name="layout" value="3 columns"/>
</actionGroup>
<actionGroup ref="CliCacheFlushActionGroup" stepKey="clickSaveConfig">
<argument name="tags" value="config"/>
</actionGroup>
<actionGroup ref="AdminOpenNewProductFormPageActionGroup" stepKey="navigateToNewProduct"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="wait1"/>
<actionGroup ref="AdminExpandProductDesignSectionActionGroup" stepKey="clickOnDesignTab"/>
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForLayoutDropDown"/>
<seeOptionIsSelected selector="{{ProductDesignSection.LayoutDropdown}}" userInput="3 columns" stepKey="see3ColumnsSelected"/>
</test>
</tests>
Loading

0 comments on commit c364929

Please sign in to comment.