Skip to content

Commit 9688409

Browse files
Merge pull request #1 from magento/2.2-develop
2.2 develop
2 parents 0d99fa8 + 17f7686 commit 9688409

File tree

54 files changed

+1118
-253
lines changed

Some content is hidden

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

54 files changed

+1118
-253
lines changed

app/code/Magento/Backup/Controller/Adminhtml/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class Index extends \Magento\Backend\App\Action
1919
*
2020
* @see _isAllowed()
2121
*/
22-
const ADMIN_RESOURCE = 'Magento_Backend::backup';
22+
const ADMIN_RESOURCE = 'Magento_Backup::backup';
2323

2424
/**
2525
* Core registry

app/code/Magento/Catalog/Helper/Data.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Catalog\Api\CategoryRepositoryInterface;
99
use Magento\Catalog\Api\ProductRepositoryInterface;
10+
use Magento\Store\Model\ScopeInterface;
1011
use Magento\Customer\Model\Session as CustomerSession;
1112
use Magento\Framework\Exception\NoSuchEntityException;
1213
use Magento\Framework\Pricing\PriceCurrencyInterface;
@@ -269,7 +270,8 @@ public function setStoreId($store)
269270

270271
/**
271272
* Return current category path or get it from current category
272-
* and creating array of categories|product paths for breadcrumbs
273+
*
274+
* Creating array of categories|product paths for breadcrumbs
273275
*
274276
* @return array
275277
*/
@@ -378,6 +380,7 @@ public function getLastViewedUrl()
378380

379381
/**
380382
* Split SKU of an item by dashes and spaces
383+
*
381384
* Words will not be broken, unless this length is greater than $length
382385
*
383386
* @param string $sku
@@ -406,14 +409,15 @@ public function getAttributeHiddenFields()
406409
/**
407410
* Retrieve Catalog Price Scope
408411
*
409-
* @return int
412+
* @return int|null
410413
*/
411414
public function getPriceScope()
412415
{
413-
return $this->scopeConfig->getValue(
416+
$priceScope = $this->scopeConfig->getValue(
414417
self::XML_PATH_PRICE_SCOPE,
415-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
418+
ScopeInterface::SCOPE_STORE
416419
);
420+
return isset($priceScope) ? (int)$priceScope : null;
417421
}
418422

419423
/**
@@ -449,7 +453,7 @@ public function isUrlDirectivesParsingAllowed()
449453
{
450454
return $this->scopeConfig->isSetFlag(
451455
self::CONFIG_PARSE_URL_DIRECTIVES,
452-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
456+
ScopeInterface::SCOPE_STORE,
453457
$this->_storeId
454458
);
455459
}
@@ -466,19 +470,22 @@ public function getPageTemplateProcessor()
466470

467471
/**
468472
* Whether to display items count for each filter option
473+
*
469474
* @param int $storeId Store view ID
470475
* @return bool
471476
*/
472477
public function shouldDisplayProductCountOnLayer($storeId = null)
473478
{
474479
return $this->scopeConfig->isSetFlag(
475480
self::XML_PATH_DISPLAY_PRODUCT_COUNT,
476-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
481+
ScopeInterface::SCOPE_STORE,
477482
$storeId
478483
);
479484
}
480485

481486
/**
487+
* Convert tax address array to address data object with country id and postcode
488+
*
482489
* @param array $taxAddress
483490
* @return \Magento\Customer\Api\Data\AddressInterface|null
484491
*/

app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ public function execute($entity, $arguments = [])
8282
__('Tier prices data should be array, but actually other type is received')
8383
);
8484
}
85-
$websiteId = $this->storeManager->getStore($entity->getStoreId())->getWebsiteId();
85+
$websiteId = (int)$this->storeManager->getStore($entity->getStoreId())->getWebsiteId();
8686
$isGlobal = $attribute->isScopeGlobal() || $websiteId === 0;
8787
$identifierField = $this->metadataPoll->getMetadata(ProductInterface::class)->getLinkField();
88-
$productId = $entity->getData($identifierField);
88+
$productId = (int)$entity->getData($identifierField);
8989

9090
// prepare original data to compare
9191
$origPrices = $entity->getOrigData($attribute->getName());
92-
$old = $this->prepareOriginalDataToCompare($origPrices, $isGlobal);
92+
$old = $this->prepareOldTierPriceToCompare($origPrices);
9393
// prepare data for save
9494
$new = $this->prepareNewDataForSave($priceRows, $isGlobal);
9595

@@ -262,19 +262,18 @@ private function isWebsiteGlobal(int $websiteId): bool
262262
}
263263

264264
/**
265+
* Prepare old data to compare.
266+
*
265267
* @param array|null $origPrices
266-
* @param bool $isGlobal
267268
* @return array
268269
*/
269-
private function prepareOriginalDataToCompare($origPrices, $isGlobal = true): array
270+
private function prepareOldTierPriceToCompare($origPrices): array
270271
{
271272
$old = [];
272273
if (is_array($origPrices)) {
273274
foreach ($origPrices as $data) {
274-
if ($isGlobal === $this->isWebsiteGlobal((int)$data['website_id'])) {
275-
$key = $this->getPriceKey($data);
276-
$old[$key] = $data;
277-
}
275+
$key = $this->getPriceKey($data);
276+
$old[$key] = $data;
278277
}
279278
}
280279

app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function testGetWithNonExistingProduct()
268268

269269
/**
270270
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
271-
* @expectedExceptionText Such image doesn't exist
271+
* @expectedExceptionMessage Such image doesn't exist
272272
*/
273273
public function testGetWithNonExistingImage()
274274
{

app/code/Magento/Catalog/Test/Unit/Model/Product/PriceModifierTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected function setUp()
5656

5757
/**
5858
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
59-
* @expectedMessage This product doesn't have tier price
59+
* @expectedExceptionMessage Product hasn't group price with such data: customerGroupId = '1', website = 1, qty = 3
6060
*/
6161
public function testRemoveWhenTierPricesNotExists()
6262
{
@@ -72,7 +72,7 @@ public function testRemoveWhenTierPricesNotExists()
7272

7373
/**
7474
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
75-
* @expectedMessage For current customerGroupId = '10' with 'qty' = 15 any tier price exist'.
75+
* @expectedExceptionMessage Product hasn't group price with such data: customerGroupId = '10', website = 1, qty = 5
7676
*/
7777
public function testRemoveTierPriceForNonExistingCustomerGroup()
7878
{
@@ -83,7 +83,7 @@ public function testRemoveTierPriceForNonExistingCustomerGroup()
8383
->will($this->returnValue($this->prices));
8484
$this->productMock->expects($this->never())->method('setData');
8585
$this->productRepositoryMock->expects($this->never())->method('save');
86-
$this->priceModifier->removeTierPrice($this->productMock, 10, 15, 1);
86+
$this->priceModifier->removeTierPrice($this->productMock, 10, 5, 1);
8787
}
8888

8989
public function testSuccessfullyRemoveTierPriceSpecifiedForAllGroups()

app/code/Magento/Catalog/Test/Unit/Model/Product/TierPriceManagementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function testSuccessDeleteTierPrice()
191191

192192
/**
193193
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
194-
* @message Such product doesn't exist
194+
* @expectedExceptionMessage No such entity.
195195
*/
196196
public function testDeleteTierPriceFromNonExistingProduct()
197197
{

app/code/Magento/Catalog/view/frontend/web/js/product/provider.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
define([
77
'underscore',
8+
'jquery',
89
'mageUtils',
910
'uiElement',
1011
'Magento_Catalog/js/product/storage/storage-service',
11-
'Magento_Customer/js/customer-data'
12-
], function (_, utils, Element, storage, customerData) {
12+
'Magento_Customer/js/customer-data',
13+
'Magento_Catalog/js/product/view/product-ids-resolver'
14+
], function (_, $, utils, Element, storage, customerData, productResolver) {
1315
'use strict';
1416

1517
return Element.extend({
@@ -135,11 +137,16 @@ define([
135137
*/
136138
filterIds: function (ids) {
137139
var _ids = {},
138-
currentTime = new Date().getTime() / 1000;
140+
currentTime = new Date().getTime() / 1000,
141+
currentProductIds = productResolver($('#product_addtocart_form'));
139142

140143
_.each(ids, function (id) {
141-
if (currentTime - id['added_at'] < ~~this.idsStorage.lifetime) {
144+
if (
145+
currentTime - id['added_at'] < ~~this.idsStorage.lifetime &&
146+
!_.contains(currentProductIds, id['product_id'])
147+
) {
142148
_ids[id['product_id']] = id;
149+
143150
}
144151
}, this);
145152

app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ public function execute()
6060
['request' => $this->getRequest()]
6161
);
6262
$data = $this->getRequest()->getPostValue();
63+
64+
$filterValues = ['from_date' => $this->_dateFilter];
65+
if ($this->getRequest()->getParam('to_date')) {
66+
$filterValues['to_date'] = $this->_dateFilter;
67+
}
68+
$inputFilter = new \Zend_Filter_Input(
69+
$filterValues,
70+
[],
71+
$data
72+
);
73+
$data = $inputFilter->getUnescaped();
6374
$id = $this->getRequest()->getParam('rule_id');
6475
if ($id) {
6576
$model = $ruleRepository->get($id);

app/code/Magento/Checkout/Test/Unit/Model/SidebarTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function testCheckQuoteItem()
9797

9898
/**
9999
* @expectedException \Magento\Framework\Exception\LocalizedException
100-
* @exceptedExceptionMessage We can't find the quote item.
100+
* @expectedExceptionMessage We can't find the quote item.
101101
*/
102102
public function testCheckQuoteItemWithException()
103103
{

app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ define([
2525
if (countryId) {
2626
if (addressData.region && addressData.region['region_id']) {
2727
regionId = addressData.region['region_id'];
28+
} else if (!addressData['region_id']) {
29+
regionId = undefined;
2830
} else if (countryId === window.checkoutConfig.defaultCountryId) {
2931
regionId = window.checkoutConfig.defaultRegionId;
3032
}

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Configurable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected function getVariationMatrix()
158158
$configurableMatrix = json_decode($configurableMatrix, true);
159159

160160
foreach ($configurableMatrix as $item) {
161-
if ($item['newProduct']) {
161+
if (isset($item['newProduct']) && $item['newProduct']) {
162162
$result[$item['variationKey']] = $this->mapData($item);
163163

164164
if (isset($item['qty'])) {

app/code/Magento/ConfigurableProduct/Model/Product/Configuration/Item/ItemProductResolver.php

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
1414
use Magento\Framework\App\Config\ScopeConfigInterface;
1515
use Magento\Catalog\Model\Product;
16+
use Magento\Store\Model\ScopeInterface;
1617

1718
/**
18-
* {@inheritdoc}
19+
* Resolves the product from a configured item.
1920
*/
2021
class ItemProductResolver implements ItemResolverInterface
2122
{
@@ -38,28 +39,22 @@ public function __construct(ScopeConfigInterface $scopeConfig)
3839
}
3940

4041
/**
41-
* {@inheritdoc}
42+
* Get the final product from a configured item by product type and selection.
43+
*
44+
* @param ItemInterface $item
45+
* @return ProductInterface
4246
*/
4347
public function getFinalProduct(ItemInterface $item): ProductInterface
4448
{
4549
/**
4650
* Show parent product thumbnail if it must be always shown according to the related setting in system config
4751
* or if child thumbnail is not available.
4852
*/
49-
$parentProduct = $item->getProduct();
50-
$finalProduct = $parentProduct;
53+
$finalProduct = $item->getProduct();
5154
$childProduct = $this->getChildProduct($item);
5255

53-
if ($childProduct !== $parentProduct) {
54-
$configValue = $this->scopeConfig->getValue(
55-
self::CONFIG_THUMBNAIL_SOURCE,
56-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
57-
);
58-
$childThumb = $childProduct->getData('thumbnail');
59-
$finalProduct =
60-
($configValue == Thumbnail::OPTION_USE_PARENT_IMAGE) || (!$childThumb || $childThumb == 'no_selection')
61-
? $parentProduct
62-
: $childProduct;
56+
if ($childProduct !== null && $this->isUseChildProduct($childProduct)) {
57+
$finalProduct = $childProduct;
6358
}
6459

6560
return $finalProduct;
@@ -69,17 +64,30 @@ public function getFinalProduct(ItemInterface $item): ProductInterface
6964
* Get item configurable child product.
7065
*
7166
* @param ItemInterface $item
72-
* @return Product
67+
* @return Product|null
7368
*/
74-
private function getChildProduct(ItemInterface $item): Product
69+
private function getChildProduct(ItemInterface $item)
7570
{
7671
$option = $item->getOptionByCode('simple_product');
77-
$product = $item->getProduct();
7872

79-
if ($option) {
80-
$product = $option->getProduct();
81-
}
73+
return $option ? $option->getProduct() : null;
74+
}
8275

83-
return $product;
76+
/**
77+
* Is need to use child product
78+
*
79+
* @param Product $childProduct
80+
* @return bool
81+
*/
82+
private function isUseChildProduct(Product $childProduct): bool
83+
{
84+
$configValue = $this->scopeConfig->getValue(
85+
self::CONFIG_THUMBNAIL_SOURCE,
86+
ScopeInterface::SCOPE_STORE
87+
);
88+
$childThumb = $childProduct->getData('thumbnail');
89+
return $configValue !== Thumbnail::OPTION_USE_PARENT_IMAGE
90+
&& $childThumb !== null
91+
&& $childThumb !== 'no_selection';
8492
}
8593
}

0 commit comments

Comments
 (0)