Skip to content

Commit 2900e74

Browse files
Merge branch '2.4-develop' into 30936-cms-perfomance
2 parents 9ee832e + 3fef6d1 commit 2900e74

File tree

149 files changed

+1912
-580
lines changed

Some content is hidden

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

149 files changed

+1912
-580
lines changed

app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
namespace Magento\Backend\Controller\Adminhtml\System\Store;
88

99
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
10+
use Magento\Store\Model\Group as StoreGroup;
11+
use Magento\Store\Model\Store;
12+
use Magento\Framework\Exception\LocalizedException;
1013

1114
/**
1215
* Class Save
@@ -33,6 +36,17 @@ private function processWebsiteSave($postData)
3336
$websiteModel->setId(null);
3437
}
3538

39+
$groupModel = $this->_objectManager->create(StoreGroup::class);
40+
$groupModel->load($websiteModel->getDefaultGroupId());
41+
$storeModel = $this->_objectManager->create(Store::class);
42+
$storeModel->load($groupModel->getDefaultStoreId());
43+
44+
if ($websiteModel->getIsDefault() && !$storeModel->isActive()) {
45+
throw new LocalizedException(
46+
__('Please enable your Store View before using this Web Site as Default')
47+
);
48+
}
49+
3650
$websiteModel->save();
3751
$this->messageManager->addSuccessMessage(__('You saved the website.'));
3852

@@ -43,13 +57,13 @@ private function processWebsiteSave($postData)
4357
* Process Store model save
4458
*
4559
* @param array $postData
46-
* @throws \Magento\Framework\Exception\LocalizedException
60+
* @throws LocalizedException
4761
* @return array
4862
*/
4963
private function processStoreSave($postData)
5064
{
51-
/** @var \Magento\Store\Model\Store $storeModel */
52-
$storeModel = $this->_objectManager->create(\Magento\Store\Model\Store::class);
65+
/** @var Store $storeModel */
66+
$storeModel = $this->_objectManager->create(Store::class);
5367
$postData['store']['name'] = $this->filterManager->removeTags($postData['store']['name']);
5468
if ($postData['store']['store_id']) {
5569
$storeModel->load($postData['store']['store_id']);
@@ -59,13 +73,13 @@ private function processStoreSave($postData)
5973
$storeModel->setId(null);
6074
}
6175
$groupModel = $this->_objectManager->create(
62-
\Magento\Store\Model\Group::class
76+
StoreGroup::class
6377
)->load(
6478
$storeModel->getGroupId()
6579
);
6680
$storeModel->setWebsiteId($groupModel->getWebsiteId());
6781
if (!$storeModel->isActive() && $storeModel->isDefault()) {
68-
throw new \Magento\Framework\Exception\LocalizedException(
82+
throw new LocalizedException(
6983
__('The default store cannot be disabled')
7084
);
7185
}
@@ -79,14 +93,14 @@ private function processStoreSave($postData)
7993
* Process StoreGroup model save
8094
*
8195
* @param array $postData
82-
* @throws \Magento\Framework\Exception\LocalizedException
96+
* @throws LocalizedException
8397
* @return array
8498
*/
8599
private function processGroupSave($postData)
86100
{
87101
$postData['group']['name'] = $this->filterManager->removeTags($postData['group']['name']);
88-
/** @var \Magento\Store\Model\Group $groupModel */
89-
$groupModel = $this->_objectManager->create(\Magento\Store\Model\Group::class);
102+
/** @var StoreGroup $groupModel */
103+
$groupModel = $this->_objectManager->create(StoreGroup::class);
90104
if ($postData['group']['group_id']) {
91105
$groupModel->load($postData['group']['group_id']);
92106
}
@@ -95,10 +109,11 @@ private function processGroupSave($postData)
95109
$groupModel->setId(null);
96110
}
97111
if (!$this->isSelectedDefaultStoreActive($postData, $groupModel)) {
98-
throw new \Magento\Framework\Exception\LocalizedException(
112+
throw new LocalizedException(
99113
__('An inactive store view cannot be saved as default store view')
100114
);
101115
}
116+
102117
$groupModel->save();
103118
$this->messageManager->addSuccessMessage(__('You saved the store.'));
104119

@@ -135,7 +150,7 @@ public function execute()
135150
}
136151
$redirectResult->setPath('adminhtml/*/');
137152
return $redirectResult;
138-
} catch (\Magento\Framework\Exception\LocalizedException $e) {
153+
} catch (LocalizedException $e) {
139154
$this->messageManager->addErrorMessage($e->getMessage());
140155
$this->_getSession()->setPostData($postData);
141156
} catch (\Exception $e) {
@@ -156,10 +171,10 @@ public function execute()
156171
* Verify if selected default store is active
157172
*
158173
* @param array $postData
159-
* @param \Magento\Store\Model\Group $groupModel
174+
* @param StoreGroup $groupModel
160175
* @return bool
161176
*/
162-
private function isSelectedDefaultStoreActive(array $postData, \Magento\Store\Model\Group $groupModel)
177+
private function isSelectedDefaultStoreActive(array $postData, StoreGroup $groupModel)
163178
{
164179
if (!empty($postData['group']['default_store_id'])) {
165180
$defaultStoreId = $postData['group']['default_store_id'];
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="AdminClearGridFiltersActionGroup">
12+
<annotations>
13+
<description>Click the Clear filters on the grid.</description>
14+
</annotations>
15+
16+
<click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters"/>
17+
<waitForPageLoad stepKey="waitForPageLoaded"/>
18+
</actionGroup>
19+
</actionGroups>

app/code/Magento/Backend/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ System,System
198198
"All Stores","All Stores"
199199
"You saved the website.","You saved the website."
200200
"The default store cannot be disabled","The default store cannot be disabled"
201+
"Please enable your Store View before using this Web Site as Default","Please enable your Store View before using this Web Site as Default"
201202
"You saved the store view.","You saved the store view."
202203
"An inactive store view cannot be saved as default store view","An inactive store view cannot be saved as default store view"
203204
"You saved the store.","You saved the store."

app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ public function getJsonConfig()
184184
$configValue = $preConfiguredValues->getData('bundle_option/' . $optionId);
185185
if ($configValue) {
186186
$defaultValues[$optionId] = $configValue;
187-
$configQty = $preConfiguredValues->getData('bundle_option_qty/' . $optionId);
188-
if ($configQty) {
189-
$options[$optionId]['selections'][$configValue]['qty'] = $configQty;
190-
}
191187
}
192188
$options = $this->processOptions($optionId, $options, $preConfiguredValues);
193189
}

app/code/Magento/Bundle/Model/CartItemProcessor.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(
5151
}
5252

5353
/**
54-
* {@inheritdoc}
54+
* @inheritDoc
5555
*/
5656
public function convertToBuyRequest(CartItemInterface $cartItem)
5757
{
@@ -73,7 +73,7 @@ public function convertToBuyRequest(CartItemInterface $cartItem)
7373
}
7474

7575
/**
76-
* {@inheritdoc}
76+
* @inheritDoc
7777
* @SuppressWarnings(PHPMD.NPathComplexity)
7878
*/
7979
public function processOptions(CartItemInterface $cartItem)
@@ -84,19 +84,21 @@ public function processOptions(CartItemInterface $cartItem)
8484
$productOptions = [];
8585
$bundleOptions = $cartItem->getBuyRequest()->getBundleOption();
8686
$bundleOptionsQty = $cartItem->getBuyRequest()->getBundleOptionQty();
87+
$bundleOptionsQty = is_array($bundleOptionsQty) ? $bundleOptionsQty : [];
8788
if (is_array($bundleOptions)) {
8889
foreach ($bundleOptions as $optionId => $optionSelections) {
8990
if (empty($optionSelections)) {
9091
continue;
9192
}
9293
$optionSelections = is_array($optionSelections) ? $optionSelections : [$optionSelections];
93-
$optionQty = isset($bundleOptionsQty[$optionId]) ? $bundleOptionsQty[$optionId] : 1;
9494

9595
/** @var \Magento\Bundle\Api\Data\BundleOptionInterface $productOption */
9696
$productOption = $this->bundleOptionFactory->create();
9797
$productOption->setOptionId($optionId);
9898
$productOption->setOptionSelections($optionSelections);
99-
$productOption->setOptionQty($optionQty);
99+
if (isset($bundleOptionsQty[$optionId])) {
100+
$productOption->setOptionQty($bundleOptionsQty[$optionId]);
101+
}
100102
$productOptions[] = $productOption;
101103
}
102104

app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ public function testGetJsonConfigFixedPriceBundleNoOption()
214214

215215
public function testGetJsonConfigFixedPriceBundle()
216216
{
217+
$optionId = 1;
218+
$optionQty = 2;
217219
$baseAmount = 123;
218220
$basePriceValue = 123123;
219221
$selections = [
@@ -230,7 +232,6 @@ public function testGetJsonConfigFixedPriceBundle()
230232
true
231233
)
232234
];
233-
234235
$bundleProductPrice = $this->getMockBuilder(Price::class)
235236
->disableOriginalConstructor()
236237
->setMethods(['getLowestPrice'])
@@ -246,10 +247,8 @@ public function testGetJsonConfigFixedPriceBundle()
246247
$this->bundleProductPriceFactory->expects($this->once())
247248
->method('create')
248249
->willReturn($bundleProductPrice);
250+
$options = [$this->createOption($optionId, 'Title `1', $selections)];
249251

250-
$options = [
251-
$this->createOption(1, 'Title `1', $selections),
252-
];
253252
$finalPriceMock = $this->getPriceMock(
254253
[
255254
'getPriceWithoutOption' => new DataObject(
@@ -289,7 +288,10 @@ public function testGetJsonConfigFixedPriceBundle()
289288
$preconfiguredValues = new DataObject(
290289
[
291290
'bundle_option' => [
292-
1 => 123123111,
291+
$optionId => [123123111],
292+
],
293+
'bundle_option_qty' => [
294+
$optionId => $optionQty,
293295
],
294296
]
295297
);
@@ -306,7 +308,8 @@ public function testGetJsonConfigFixedPriceBundle()
306308
$this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']);
307309
$this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']);
308310
$this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']);
309-
$this->assertEquals([1], $jsonConfig['positions']);
311+
$this->assertEquals([$optionId], $jsonConfig['positions']);
312+
$this->assertEquals($optionQty, $jsonConfig['options'][$optionId]['selections'][1123]['qty']);
310313
}
311314

312315
/**

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Bundle\Model\Product\Type;
1212
use Magento\Bundle\Model\ResourceModel\BundleFactory;
1313
use Magento\Bundle\Model\ResourceModel\Option\Collection;
14-
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
1514
use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
1615
use Magento\Bundle\Model\ResourceModel\Selection\CollectionFactory;
1716
use Magento\Bundle\Model\Selection;
@@ -28,6 +27,7 @@
2827
use Magento\CatalogInventory\Api\StockStateInterface;
2928
use Magento\CatalogInventory\Model\StockRegistry;
3029
use Magento\CatalogInventory\Model\StockState;
30+
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
3131
use Magento\Framework\DataObject;
3232
use Magento\Framework\EntityManager\EntityMetadataInterface;
3333
use Magento\Framework\EntityManager\MetadataPool;
@@ -1548,6 +1548,10 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
15481548
->disableOriginalConstructor()
15491549
->getMock();
15501550

1551+
$buyRequest->method('getOptions')
1552+
->willReturn([333 => ['type' => 'image/jpeg']]);
1553+
$option->method('getId')
1554+
->willReturn(333);
15511555
$this->parentClass($group, $option, $buyRequest, $product);
15521556

15531557
$product->expects($this->any())
@@ -1556,6 +1560,8 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
15561560
$buyRequest->expects($this->once())
15571561
->method('getBundleOption')
15581562
->willReturn([0, '', 'str']);
1563+
$group->expects($this->once())
1564+
->method('validateUserValue');
15591565

15601566
$result = $this->model->prepareForCartAdvanced($buyRequest, $product);
15611567
$this->assertEquals('Please specify product option(s).', $result);

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
declare(strict_types=1);
76

87
namespace Magento\Catalog\Model\Product\Type;
98

@@ -605,7 +604,11 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
605604
if ($product->getSkipCheckRequiredOption() !== true) {
606605
$group->validateUserValue($optionsFromRequest);
607606
} elseif ($optionsFromRequest !== null && isset($optionsFromRequest[$option->getId()])) {
608-
$transport->options[$option->getId()] = $optionsFromRequest[$option->getId()];
607+
if (is_array($optionsFromRequest[$option->getId()])) {
608+
$group->validateUserValue($optionsFromRequest);
609+
} else {
610+
$transport->options[$option->getId()] = $optionsFromRequest[$option->getId()];
611+
}
609612
}
610613

611614
} catch (LocalizedException $e) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="AdminChangeWebSiteAssignedToProductActionGroup" extends="AddWebsiteToProductActionGroup">
12+
<annotations>
13+
<description>Extends AddWebsiteToProductActionGroup. Changes website assigned to product from websiteToDeselect to website</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="websiteToDeselect" type="string"/>
17+
</arguments>
18+
19+
<uncheckOption selector="{{ProductInWebsitesSection.website(websiteToDeselect)}}" stepKey="uncheckWebsite" after="checkWebsite"/>
20+
</actionGroup>
21+
</actionGroups>
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
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-
-->
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+
-->
88

9-
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11-
<actionGroup name="AdminCheckProductOnProductGridActionGroup">
12-
<annotations>
13-
<description>Check the checkbox for the product on the Product Grid</description>
14-
</annotations>
15-
<arguments>
16-
<argument name="product" type="entity"/>
17-
</arguments>
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminCheckProductOnProductGridActionGroup">
11+
<annotations>
12+
<description>Check the checkbox for the product on the Product Grid</description>
13+
</annotations>
14+
<arguments>
15+
<argument name="product" type="entity"/>
16+
</arguments>
1817

19-
<checkOption selector="{{AdminProductGridSection.productRowCheckboxBySku(product.sku)}}" stepKey="selectProduct"/>
18+
<checkOption selector="{{AdminProductGridSection.productRowCheckboxBySku(product.sku)}}" stepKey="selectProduct"/>
2019

21-
</actionGroup>
22-
</actionGroups>
20+
</actionGroup>
21+
</actionGroups>

0 commit comments

Comments
 (0)