Skip to content

Commit 791d006

Browse files
authored
Merge branch '2.4-develop' into ref-assertion-product-details-storefront
2 parents 8ae0c79 + 8631818 commit 791d006

File tree

30 files changed

+922
-203
lines changed

30 files changed

+922
-203
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'];

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/Checkout/view/frontend/templates/cart/item/default.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
4848
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
4949
<dd>
5050
<?php if (isset($_formatedOptionValue['full_view'])) :?>
51-
<?= $block->escapeHtml($_formatedOptionValue['full_view']) ?>
52-
<?php else :?>
51+
<?= $block->escapeHtml($_formatedOptionValue['full_view']) ?>
52+
<?php else :?>
5353
<?= $block->escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
5454
<?php endif; ?>
5555
</dd>

app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
*/
2323
class Builder
2424
{
25+
private const ELASTIC_INT_MAX = 2147483647;
26+
2527
/**
2628
* @var Config
2729
* @since 100.2.2
@@ -83,18 +85,18 @@ public function initQuery(RequestInterface $request)
8385
{
8486
$dimension = current($request->getDimensions());
8587
$storeId = $this->scopeResolver->getScope($dimension->getValue())->getId();
86-
8788
$searchQuery = [
8889
'index' => $this->searchIndexNameResolver->getIndexName($storeId, $request->getIndex()),
8990
'type' => $this->clientConfig->getEntityType(),
9091
'body' => [
91-
'from' => $request->getFrom(),
92+
'from' => min(self::ELASTIC_INT_MAX, $request->getFrom()),
9293
'size' => $request->getSize(),
9394
'stored_fields' => ['_id', '_score'],
9495
'sort' => $this->sortBuilder->getSort($request),
9596
'query' => [],
9697
],
9798
];
99+
98100
return $searchQuery;
99101
}
100102

app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
class Builder extends Elasticsearch5Builder
2525
{
26+
private const ELASTIC_INT_MAX = 2147483647;
27+
2628
/**
2729
* @var Sort
2830
*/
@@ -61,7 +63,7 @@ public function initQuery(RequestInterface $request)
6163
'index' => $this->searchIndexNameResolver->getIndexName($storeId, $request->getIndex()),
6264
'type' => $this->clientConfig->getEntityType(),
6365
'body' => [
64-
'from' => $request->getFrom(),
66+
'from' => min(self::ELASTIC_INT_MAX, $request->getFrom()),
6567
'size' => $request->getSize(),
6668
'fields' => ['_id', '_score'],
6769
'sort' => $this->sortBuilder->getSort($request),

0 commit comments

Comments
 (0)