Skip to content

Commit bc4abf6

Browse files
merge magento-commerce/2.4-develop into magento-tsg/2.4-develop-pr131
2 parents 9b8e3fd + c364929 commit bc4abf6

File tree

148 files changed

+2270
-395
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+2270
-395
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertAdminDashboardDisplayedWithNoErrorsActionGroup">
12+
<annotations>
13+
<description>Checks if Dashboard is displayed properly</description>
14+
</annotations>
15+
16+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramOrderContentTab}}" stepKey="seeOrderContentTab"/>
17+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramContent}}" stepKey="seeDiagramContent"/>
18+
<click selector="{{AdminDashboardSection.dashboardDiagramAmounts}}" stepKey="clickDashboardAmount"/>
19+
<waitForLoadingMaskToDisappear stepKey="waitForDashboardAmountLoading"/>
20+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramAmountsContentTab}}" stepKey="seeDiagramAmountContent"/>
21+
<seeElement selector="{{AdminDashboardSection.dashboardDiagramTotals}}" stepKey="seeAmountTotals"/>
22+
<dontSeeJsError stepKey="dontSeeJsError"/>
23+
</actionGroup>
24+
</actionGroups>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminCheckDashboardWithChartsTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Google Charts on Magento dashboard"/>
15+
<title value="Admin should see Google chart on Magento dashboard"/>
16+
<description value="Google chart on Magento dashboard page is displaying properly"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MAGETWO-98934"/>
19+
<useCaseId value="MAGETWO-98584"/>
20+
<group value="backend"/>
21+
</annotations>
22+
<before>
23+
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>
24+
<createData entity="SimpleProduct2" stepKey="createProduct">
25+
<field key="price">150</field>
26+
</createData>
27+
<createData entity="Simple_US_Customer" stepKey="createCustomer">
28+
<field key="firstname">John1</field>
29+
<field key="lastname">Doe1</field>
30+
</createData>
31+
<createData entity="CustomerCart" stepKey="createCustomerCart">
32+
<requiredEntity createDataKey="createCustomer"/>
33+
</createData>
34+
<createData entity="CustomerCartItem" stepKey="addCartItem">
35+
<requiredEntity createDataKey="createCustomerCart"/>
36+
<requiredEntity createDataKey="createProduct"/>
37+
</createData>
38+
<createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress">
39+
<requiredEntity createDataKey="createCustomerCart"/>
40+
</createData>
41+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
42+
</before>
43+
<after>
44+
<magentoCLI command="config:set admin/dashboard/enable_charts 0" stepKey="setDisableChartsAsDefault"/>
45+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
46+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
47+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
48+
</after>
49+
50+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityBefore"/>
51+
52+
<updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformation">
53+
<requiredEntity createDataKey="createCustomerCart"/>
54+
</updateData>
55+
<createData entity="Invoice" stepKey="invoiceOrder">
56+
<requiredEntity createDataKey="createCustomerCart"/>
57+
</createData>
58+
<createData entity="Shipment" stepKey="shipOrder">
59+
<requiredEntity createDataKey="createCustomerCart"/>
60+
</createData>
61+
62+
<reloadPage stepKey="refreshPage"/>
63+
<actionGroup ref="AssertAdminDashboardDisplayedWithNoErrorsActionGroup" stepKey="assertAdminDashboardNotBroken"/>
64+
<grabTextFrom selector="{{AdminDashboardSection.dashboardTotals('Quantity')}}" stepKey="grabQuantityAfter"/>
65+
<assertGreaterThan stepKey="checkQuantityWasChanged">
66+
<actualResult type="const">$grabQuantityAfter</actualResult>
67+
<expectedResult type="const">$grabQuantityBefore</expectedResult>
68+
</assertGreaterThan>
69+
</test>
70+
</tests>

app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsTest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@
88

99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11-
<test name="AdminDashboardWithChartsTest">
11+
<test name="AdminDashboardWithChartsTest" deprecated="Use AdminCheckDashboardWithChartsTest instead">
1212
<annotations>
1313
<features value="Backend"/>
1414
<stories value="Google Charts on Magento dashboard"/>
15-
<title value="Admin should see Google chart on Magento dashboard"/>
15+
<title value="DEPRECATED. Admin should see Google chart on Magento dashboard"/>
1616
<description value="Google chart on Magento dashboard page is displaying properly"/>
1717
<severity value="MAJOR"/>
1818
<testCaseId value="MAGETWO-98934"/>
1919
<useCaseId value="MAGETWO-98584"/>
2020
<group value="backend"/>
21+
<skip>
22+
<issueId value="DEPRECATED">Use AdminCheckDashboardWithChartsTest instead</issueId>
23+
</skip>
2124
</annotations>
2225
<before>
2326
<magentoCLI command="config:set admin/dashboard/enable_charts 1" stepKey="setEnableCharts"/>

app/code/Magento/Backend/view/adminhtml/templates/store/switcher.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ script;
200200
setLocation(url);
201201
';
202202
} else {
203-
$scriptString .= <<<script
203+
$scriptString .= <<<'script'
204204
jQuery('#preview_selected_store').val(scopeId);
205205
jQuery('#preview_form').submit();
206206

app/code/Magento/Catalog/Model/Category.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,10 @@ public function reindex()
11591159
*/
11601160
public function afterDeleteCommit()
11611161
{
1162-
$this->reindex();
1162+
if ($this->getIsActive() || $this->getDeletedChildrenIds()) {
1163+
$this->reindex();
1164+
}
1165+
11631166
return parent::afterDeleteCommit();
11641167
}
11651168

app/code/Magento/Catalog/Model/Product.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,6 @@ public function getStoreIds()
828828
if (!$this->hasStoreIds()) {
829829
$storeIds = [];
830830
if ($websiteIds = $this->getWebsiteIds()) {
831-
if (!$this->isObjectNew() && $this->_storeManager->isSingleStoreMode()) {
832-
$websiteIds = array_keys($websiteIds);
833-
}
834831
foreach ($websiteIds as $websiteId) {
835832
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
836833
$storeIds[] = $websiteStores;

app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,55 @@
77

88
namespace Magento\Catalog\Model\Product\Option;
99

10+
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
11+
use Magento\Catalog\Api\Data\ProductInterface;
1012
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface as OptionRepository;
13+
use Magento\Catalog\Model\Product\Option;
14+
use Magento\Framework\App\ObjectManager;
1115
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
16+
use Magento\Catalog\Model\ResourceModel\Product\Relation;
17+
use Magento\Framework\Exception\CouldNotSaveException;
1218

1319
/**
14-
* Class SaveHandler
20+
* SaveHandler for product option
21+
*
22+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1523
*/
1624
class SaveHandler implements ExtensionInterface
1725
{
26+
/**
27+
* @var string[]
28+
*/
29+
private $compositeProductTypes = ['grouped', 'configurable', 'bundle'];
30+
1831
/**
1932
* @var OptionRepository
2033
*/
2134
protected $optionRepository;
2235

36+
/**
37+
* @var Relation
38+
*/
39+
private $relation;
40+
2341
/**
2442
* @param OptionRepository $optionRepository
43+
* @param Relation|null $relation
2544
*/
2645
public function __construct(
27-
OptionRepository $optionRepository
46+
OptionRepository $optionRepository,
47+
?Relation $relation = null
2848
) {
2949
$this->optionRepository = $optionRepository;
50+
$this->relation = $relation ?: ObjectManager::getInstance()->get(Relation::class);
3051
}
3152

3253
/**
3354
* Perform action on relation/extension attribute
3455
*
3556
* @param object $entity
3657
* @param array $arguments
37-
* @return \Magento\Catalog\Api\Data\ProductInterface|object
58+
* @return ProductInterface|object
3859
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3960
*/
4061
public function execute($entity, $arguments = [])
@@ -47,20 +68,19 @@ public function execute($entity, $arguments = [])
4768
$optionIds = [];
4869

4970
if ($options) {
50-
$optionIds = array_map(function ($option) {
51-
/** @var \Magento\Catalog\Model\Product\Option $option */
71+
$optionIds = array_map(function (Option $option) {
5272
return $option->getOptionId();
5373
}, $options);
5474
}
5575

56-
/** @var \Magento\Catalog\Api\Data\ProductInterface $entity */
76+
/** @var ProductInterface $entity */
5777
foreach ($this->optionRepository->getProductOptions($entity) as $option) {
5878
if (!in_array($option->getOptionId(), $optionIds)) {
5979
$this->optionRepository->delete($option);
6080
}
6181
}
6282
if ($options) {
63-
$this->processOptionsSaving($options, (bool)$entity->dataHasChangedFor('sku'), (string)$entity->getSku());
83+
$this->processOptionsSaving($options, (bool)$entity->dataHasChangedFor('sku'), $entity);
6484
}
6585

6686
return $entity;
@@ -71,15 +91,43 @@ public function execute($entity, $arguments = [])
7191
*
7292
* @param array $options
7393
* @param bool $hasChangedSku
74-
* @param string $newSku
94+
* @param ProductInterface $product
95+
* @return void
96+
* @throws CouldNotSaveException
7597
*/
76-
private function processOptionsSaving(array $options, bool $hasChangedSku, string $newSku)
98+
private function processOptionsSaving(array $options, bool $hasChangedSku, ProductInterface $product): void
7799
{
100+
$isProductHasRelations = $this->isProductHasRelations($product);
101+
/** @var ProductCustomOptionInterface $option */
78102
foreach ($options as $option) {
103+
if (!$isProductHasRelations && $option->getIsRequire()) {
104+
$message = 'Required custom options cannot be added to a simple product'
105+
. ' that is a part of a composite product.';
106+
throw new CouldNotSaveException(__($message));
107+
}
108+
79109
if ($hasChangedSku && $option->hasData('product_sku')) {
80-
$option->setProductSku($newSku);
110+
$option->setProductSku($product->getSku());
81111
}
82112
$this->optionRepository->save($option);
83113
}
84114
}
115+
116+
/**
117+
* Check if product doesn't belong to composite product
118+
*
119+
* @param ProductInterface $product
120+
* @return bool
121+
*/
122+
private function isProductHasRelations(ProductInterface $product): bool
123+
{
124+
$result = true;
125+
if (!in_array($product->getId(), $this->compositeProductTypes)
126+
&& $this->relation->getRelationsByChildren([$product->getId()])
127+
) {
128+
$result = false;
129+
}
130+
131+
return $result;
132+
}
85133
}

app/code/Magento/Catalog/Model/ResourceModel/Category.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@ protected function _beforeDelete(\Magento\Framework\DataObject $object)
232232
*/
233233
protected function _afterDelete(DataObject $object)
234234
{
235-
$this->indexerProcessor->markIndexerAsInvalid();
235+
if ($object->getIsActive() || $object->getDeletedChildrenIds()) {
236+
$this->indexerProcessor->markIndexerAsInvalid();
237+
}
238+
236239
return parent::_afterDelete($object);
237240
}
238241

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminExpandProductDesignSectionActionGroup">
12+
<annotations>
13+
<description>Expand the Design section on the Product Details page in Admin.</description>
14+
</annotations>
15+
16+
<click selector="{{ProductDesignSection.DesignTab}}" stepKey="clickDesignTab"/>
17+
<waitForPageLoad stepKey="waitForTabOpen"/>
18+
</actionGroup>
19+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminProductAttributeSetVisibleInAdvancedSearchActionGroup">
11+
<annotations>
12+
<description>Set 'Visible in Advanced Search' value for product attribute</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="isVisibleInAdvancedSearch" type="string" defaultValue="Yes"/>
16+
</arguments>
17+
18+
<scrollToTopOfPage stepKey="scrollToTopOfPage"/>
19+
<click selector="{{StorefrontPropertiesSection.StoreFrontPropertiesTab}}" stepKey="clickStorefrontPropertiesTab"/>
20+
<waitForElementVisible selector="{{AdvancedAttributePropertiesSection.VisibleInAdvancedSearch}}" stepKey="waitForVisibleInAdvancedSearchElementVisible"/>
21+
<selectOption selector="{{AdvancedAttributePropertiesSection.VisibleInAdvancedSearch}}" userInput="{{isVisibleInAdvancedSearch}}" stepKey="setVisibleInAdvancedSearchValue"/>
22+
</actionGroup>
23+
</actionGroups>

0 commit comments

Comments
 (0)