Skip to content

Commit 89c9992

Browse files
author
Yevhen Miroshnychenko
committed
Merge branch '2.3-develop' into MC-19421
2 parents 8afbd8c + 8eb50bf commit 89c9992

File tree

45 files changed

+917
-270
lines changed

Some content is hidden

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

45 files changed

+917
-270
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,12 +832,14 @@ public function getStoreIds()
832832
if (!$this->hasStoreIds()) {
833833
$storeIds = [];
834834
if ($websiteIds = $this->getWebsiteIds()) {
835-
if ($this->_storeManager->isSingleStoreMode()) {
835+
if (!$this->isObjectNew() && $this->_storeManager->isSingleStoreMode()) {
836836
$websiteIds = array_keys($websiteIds);
837837
}
838838
foreach ($websiteIds as $websiteId) {
839839
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
840-
$storeIds = array_merge($storeIds, $websiteStores);
840+
foreach ($websiteStores as $websiteStore) {
841+
$storeIds []= $websiteStore;
842+
}
841843
}
842844
}
843845
$this->setStoreIds($storeIds);
@@ -920,9 +922,9 @@ public function beforeSave()
920922
//Validate changing of design.
921923
$userType = $this->getUserContext()->getUserType();
922924
if ((
923-
$userType === UserContextInterface::USER_TYPE_ADMIN
925+
$userType === UserContextInterface::USER_TYPE_ADMIN
924926
|| $userType === UserContextInterface::USER_TYPE_INTEGRATION
925-
)
927+
)
926928
&& !$this->getAuthorization()->isAllowed('Magento_Catalog::edit_product_design')
927929
) {
928930
$this->setData('custom_design', $this->getOrigData('custom_design'));

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,19 @@ public function getList($sku, $customerGroupId)
182182
: $customerGroupId);
183183

184184
$prices = [];
185-
foreach ($product->getData('tier_price') as $price) {
186-
if ((is_numeric($customerGroupId) && (int) $price['cust_group'] === (int) $customerGroupId)
187-
|| ($customerGroupId === 'all' && $price['all_groups'])
188-
) {
189-
/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
190-
$tierPrice = $this->priceFactory->create();
191-
$tierPrice->setValue($price[$priceKey])
192-
->setQty($price['price_qty'])
193-
->setCustomerGroupId($cgi);
194-
$prices[] = $tierPrice;
185+
$tierPrices = $product->getData('tier_price');
186+
if ($tierPrices !== null) {
187+
foreach ($tierPrices as $price) {
188+
if ((is_numeric($customerGroupId) && (int) $price['cust_group'] === (int) $customerGroupId)
189+
|| ($customerGroupId === 'all' && $price['all_groups'])
190+
) {
191+
/** @var \Magento\Catalog\Api\Data\ProductTierPriceInterface $tierPrice */
192+
$tierPrice = $this->priceFactory->create();
193+
$tierPrice->setValue($price[$priceKey])
194+
->setQty($price['price_qty'])
195+
->setCustomerGroupId($cgi);
196+
$prices[] = $tierPrice;
197+
}
195198
}
196199
}
197200
return $prices;

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\Api\ExtensibleDataInterface;
1414
use Magento\Framework\Api\ExtensionAttributesFactory;
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
16+
use Magento\Store\Model\StoreManagerInterface;
1617

1718
/**
1819
* Product Test
@@ -207,6 +208,11 @@ class ProductTest extends \PHPUnit\Framework\TestCase
207208
*/
208209
private $eavConfig;
209210

211+
/**
212+
* @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
213+
*/
214+
private $storeManager;
215+
210216
/**
211217
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
212218
*/
@@ -303,13 +309,13 @@ protected function setUp()
303309
->disableOriginalConstructor()
304310
->getMock();
305311

306-
$storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
312+
$this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
307313
->disableOriginalConstructor()
308314
->getMockForAbstractClass();
309-
$storeManager->expects($this->any())
315+
$this->storeManager->expects($this->any())
310316
->method('getStore')
311317
->will($this->returnValue($this->store));
312-
$storeManager->expects($this->any())
318+
$this->storeManager->expects($this->any())
313319
->method('getWebsite')
314320
->will($this->returnValue($this->website));
315321
$this->indexerRegistryMock = $this->createPartialMock(
@@ -394,7 +400,7 @@ protected function setUp()
394400
'extensionFactory' => $this->extensionAttributesFactory,
395401
'productPriceIndexerProcessor' => $this->productPriceProcessor,
396402
'catalogProductOptionFactory' => $optionFactory,
397-
'storeManager' => $storeManager,
403+
'storeManager' => $this->storeManager,
398404
'resource' => $this->resource,
399405
'registry' => $this->registry,
400406
'moduleManager' => $this->moduleManager,
@@ -450,6 +456,48 @@ public function testGetStoreIds()
450456
$this->assertEquals($expectedStoreIds, $this->model->getStoreIds());
451457
}
452458

459+
/**
460+
* @dataProvider getSingleStoreIds
461+
* @param bool $isObjectNew
462+
*/
463+
public function testGetStoreSingleSiteModelIds(
464+
bool $isObjectNew
465+
) {
466+
$websiteIDs = [0 => 2];
467+
$this->model->setWebsiteIds(
468+
!$isObjectNew ? $websiteIDs : array_flip($websiteIDs)
469+
);
470+
471+
$this->model->isObjectNew($isObjectNew);
472+
473+
$this->storeManager->expects(
474+
$this->exactly(
475+
(int) !$isObjectNew
476+
)
477+
)
478+
->method('isSingleStoreMode')
479+
->will($this->returnValue(true));
480+
481+
$this->website->expects(
482+
$this->once()
483+
)->method('getStoreIds')
484+
->will($this->returnValue($websiteIDs));
485+
486+
$this->assertEquals($websiteIDs, $this->model->getStoreIds());
487+
}
488+
489+
public function getSingleStoreIds()
490+
{
491+
return [
492+
[
493+
false
494+
],
495+
[
496+
true
497+
],
498+
];
499+
}
500+
453501
public function testGetStoreId()
454502
{
455503
$this->model->setStoreId(3);
@@ -1221,8 +1269,7 @@ public function testGetMediaGalleryImagesMerging()
12211269
{
12221270
$mediaEntries =
12231271
[
1224-
'images' =>
1225-
[
1272+
'images' => [
12261273
[
12271274
'value_id' => 1,
12281275
'file' => 'imageFile.jpg',

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartWithDisableMiniCartSidebarTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<argument name="total" value="110.00"/>
110110
</actionGroup>
111111

112-
<!--Enabled Shopping Cart Sidebar -->
112+
<!--Enabled Mini Cart -->
113113
<magentoCLI stepKey="enableShoppingCartSidebar" command="config:set checkout/sidebar/display 1"/>
114114
<magentoCLI command="cache:flush" stepKey="flushCache"/>
115115
<reloadPage stepKey="reloadThePage"/>

app/code/Magento/Checkout/etc/adminhtml/system.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
</field>
5858
</group>
5959
<group id="sidebar" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
60-
<label>Shopping Cart Sidebar</label>
60+
<label>Mini Cart</label>
6161
<field id="display" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
62-
<label>Display Shopping Cart Sidebar</label>
62+
<label>Display Mini Cart</label>
6363
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
6464
</field>
6565
<field id="count" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ Shipping,Shipping
156156
"Number of Items to Display Pager","Number of Items to Display Pager"
157157
"My Cart Link","My Cart Link"
158158
"Display Cart Summary","Display Cart Summary"
159-
"Shopping Cart Sidebar","Shopping Cart Sidebar"
160-
"Display Shopping Cart Sidebar","Display Shopping Cart Sidebar"
159+
"Mini Cart","Mini Cart"
160+
"Display Mini Cart","Display Mini Cart"
161161
"Number of Items to Display Scrollbar","Number of Items to Display Scrollbar"
162162
"Maximum Number of Items to Display","Maximum Number of Items to Display"
163163
"Payment Failed Emails","Payment Failed Emails"

app/code/Magento/Checkout/view/frontend/templates/cart/form.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<span><?= $block->escapeHtml(__('Continue Shopping')) ?></span>
5757
</a>
5858
<?php endif; ?>
59-
<button type="submit"
59+
<button type="button"
6060
name="update_cart_action"
6161
data-cart-empty=""
6262
value="empty_cart"

app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
104104
value="<?= $block->escapeHtmlAttr($block->getQty()) ?>"
105105
type="number"
106106
size="4"
107+
step="any"
107108
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
108109
class="input-text qty"
109110
data-validate="{required:true,'validate-greater-than-zero':true}"

app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ define([
1414
_create: function () {
1515
var items, i, reload;
1616

17-
$(this.options.emptyCartButton).on('click', $.proxy(function (event) {
18-
if (event.detail === 0) {
19-
return;
20-
}
21-
17+
$(this.options.emptyCartButton).on('click', $.proxy(function () {
2218
$(this.options.emptyCartButton).attr('name', 'update_cart_action_temp');
2319
$(this.options.updateCartActionContainer)
2420
.attr('name', 'update_cart_action').attr('value', 'empty_cart');
21+
22+
if ($(this.options.emptyCartButton).parents('form').length > 0) {
23+
$(this.options.emptyCartButton).parents('form').submit();
24+
}
2525
}, this));
2626
items = $.find('[data-role="cart-item-qty"]');
2727

app/code/Magento/Customer/Model/AttributeMetadataConverter.php

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,36 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Customer\Model;
79

810
use Magento\Customer\Api\Data\OptionInterfaceFactory;
911
use Magento\Customer\Api\Data\ValidationRuleInterfaceFactory;
1012
use Magento\Customer\Api\Data\AttributeMetadataInterfaceFactory;
1113
use Magento\Eav\Api\Data\AttributeDefaultValueInterface;
14+
use Magento\Framework\App\Config\ScopeConfigInterface;
15+
use Magento\Framework\App\ObjectManager;
1216

1317
/**
1418
* Converter for AttributeMetadata
1519
*/
1620
class AttributeMetadataConverter
1721
{
22+
/**
23+
* Attribute Code get options from system config
24+
*
25+
* @var array
26+
*/
27+
private const ATTRIBUTE_CODE_LIST_FROM_SYSTEM_CONFIG = ['prefix', 'suffix'];
28+
29+
/**
30+
* XML Path to get address config
31+
*
32+
* @var string
33+
*/
34+
private const XML_CUSTOMER_ADDRESS = 'customer/address/';
35+
1836
/**
1937
* @var OptionInterfaceFactory
2038
*/
@@ -35,24 +53,32 @@ class AttributeMetadataConverter
3553
*/
3654
protected $dataObjectHelper;
3755

56+
/**
57+
* @var ScopeConfigInterface
58+
*/
59+
private $scopeConfig;
60+
3861
/**
3962
* Initialize the Converter
4063
*
4164
* @param OptionInterfaceFactory $optionFactory
4265
* @param ValidationRuleInterfaceFactory $validationRuleFactory
4366
* @param AttributeMetadataInterfaceFactory $attributeMetadataFactory
4467
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
68+
* @param ScopeConfigInterface $scopeConfig
4569
*/
4670
public function __construct(
4771
OptionInterfaceFactory $optionFactory,
4872
ValidationRuleInterfaceFactory $validationRuleFactory,
4973
AttributeMetadataInterfaceFactory $attributeMetadataFactory,
50-
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper
74+
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
75+
ScopeConfigInterface $scopeConfig = null
5176
) {
5277
$this->optionFactory = $optionFactory;
5378
$this->validationRuleFactory = $validationRuleFactory;
5479
$this->attributeMetadataFactory = $attributeMetadataFactory;
5580
$this->dataObjectHelper = $dataObjectHelper;
81+
$this->scopeConfig = $scopeConfig ?? ObjectManager::getInstance()->get(ScopeConfigInterface::class);
5682
}
5783

5884
/**
@@ -64,28 +90,34 @@ public function __construct(
6490
public function createMetadataAttribute($attribute)
6591
{
6692
$options = [];
67-
if ($attribute->usesSource()) {
68-
foreach ($attribute->getSource()->getAllOptions() as $option) {
69-
$optionDataObject = $this->optionFactory->create();
70-
if (!is_array($option['value'])) {
71-
$optionDataObject->setValue($option['value']);
72-
} else {
73-
$optionArray = [];
74-
foreach ($option['value'] as $optionArrayValues) {
75-
$optionObject = $this->optionFactory->create();
76-
$this->dataObjectHelper->populateWithArray(
77-
$optionObject,
78-
$optionArrayValues,
79-
\Magento\Customer\Api\Data\OptionInterface::class
80-
);
81-
$optionArray[] = $optionObject;
93+
94+
if (in_array($attribute->getAttributeCode(), self::ATTRIBUTE_CODE_LIST_FROM_SYSTEM_CONFIG)) {
95+
$options = $this->getOptionFromConfig($attribute->getAttributeCode());
96+
} else {
97+
if ($attribute->usesSource()) {
98+
foreach ($attribute->getSource()->getAllOptions() as $option) {
99+
$optionDataObject = $this->optionFactory->create();
100+
if (!is_array($option['value'])) {
101+
$optionDataObject->setValue($option['value']);
102+
} else {
103+
$optionArray = [];
104+
foreach ($option['value'] as $optionArrayValues) {
105+
$optionObject = $this->optionFactory->create();
106+
$this->dataObjectHelper->populateWithArray(
107+
$optionObject,
108+
$optionArrayValues,
109+
\Magento\Customer\Api\Data\OptionInterface::class
110+
);
111+
$optionArray[] = $optionObject;
112+
}
113+
$optionDataObject->setOptions($optionArray);
82114
}
83-
$optionDataObject->setOptions($optionArray);
115+
$optionDataObject->setLabel($option['label']);
116+
$options[] = $optionDataObject;
84117
}
85-
$optionDataObject->setLabel($option['label']);
86-
$options[] = $optionDataObject;
87118
}
88119
}
120+
89121
$validationRules = [];
90122
foreach ((array)$attribute->getValidateRules() as $name => $value) {
91123
$validationRule = $this->validationRuleFactory->create()
@@ -122,4 +154,26 @@ public function createMetadataAttribute($attribute)
122154
->setIsFilterableInGrid($attribute->getIsFilterableInGrid())
123155
->setIsSearchableInGrid($attribute->getIsSearchableInGrid());
124156
}
157+
158+
/**
159+
* Get option from System Config instead of Use Source (Prefix, Suffix)
160+
*
161+
* @param string $attributeCode
162+
* @return \Magento\Customer\Api\Data\OptionInterface[]
163+
*/
164+
private function getOptionFromConfig($attributeCode)
165+
{
166+
$result = [];
167+
$value = $this->scopeConfig->getValue(self::XML_CUSTOMER_ADDRESS . $attributeCode . '_options');
168+
if ($value) {
169+
$optionArray = explode(';', $value);
170+
foreach ($optionArray as $value) {
171+
$optionObject = $this->optionFactory->create();
172+
$optionObject->setLabel($value);
173+
$optionObject->setValue($value);
174+
$result[] = $optionObject;
175+
}
176+
}
177+
return $result;
178+
}
125179
}

0 commit comments

Comments
 (0)