Skip to content

Commit 5dd5cc0

Browse files
committed
Merge remote-tracking branch 'origin/2.2-develop' into 2.2-dev-pan-2.3.10
2 parents d2392b1 + 17f7686 commit 5dd5cc0

File tree

75 files changed

+1474
-342
lines changed

Some content is hidden

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

75 files changed

+1474
-342
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/Model/Product/Url.php

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

88
use Magento\UrlRewrite\Model\UrlFinderInterface;
99
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
1011

1112
/**
1213
* Product Url model
@@ -45,38 +46,37 @@ class Url extends \Magento\Framework\DataObject
4546
*/
4647
protected $urlFinder;
4748

49+
/**
50+
* @var ScopeConfigInterface
51+
*/
52+
private $scopeConfig;
53+
4854
/**
4955
* @param \Magento\Framework\UrlFactory $urlFactory
5056
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
5157
* @param \Magento\Framework\Filter\FilterManager $filter
5258
* @param \Magento\Framework\Session\SidResolverInterface $sidResolver
5359
* @param UrlFinderInterface $urlFinder
5460
* @param array $data
61+
* @param ScopeConfigInterface|null $scopeConfig
5562
*/
5663
public function __construct(
5764
\Magento\Framework\UrlFactory $urlFactory,
5865
\Magento\Store\Model\StoreManagerInterface $storeManager,
5966
\Magento\Framework\Filter\FilterManager $filter,
6067
\Magento\Framework\Session\SidResolverInterface $sidResolver,
6168
UrlFinderInterface $urlFinder,
62-
array $data = []
69+
array $data = [],
70+
ScopeConfigInterface $scopeConfig = null
6371
) {
6472
parent::__construct($data);
6573
$this->urlFactory = $urlFactory;
6674
$this->storeManager = $storeManager;
6775
$this->filter = $filter;
6876
$this->sidResolver = $sidResolver;
6977
$this->urlFinder = $urlFinder;
70-
}
71-
72-
/**
73-
* Retrieve URL Instance
74-
*
75-
* @return \Magento\Framework\UrlInterface
76-
*/
77-
private function getUrlInstance()
78-
{
79-
return $this->urlFactory->create();
78+
$this->scopeConfig = $scopeConfig ?:
79+
\Magento\Framework\App\ObjectManager::getInstance()->get(ScopeConfigInterface::class);
8080
}
8181

8282
/**
@@ -157,10 +157,19 @@ public function getUrl(\Magento\Catalog\Model\Product $product, $params = [])
157157
UrlRewrite::ENTITY_TYPE => \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator::ENTITY_TYPE,
158158
UrlRewrite::STORE_ID => $storeId,
159159
];
160-
if ($categoryId) {
160+
$useCategories = $this->scopeConfig->getValue(
161+
\Magento\Catalog\Helper\Product::XML_PATH_PRODUCT_URL_USE_CATEGORY,
162+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
163+
);
164+
165+
if ($useCategories && $categoryId) {
161166
$filterData[UrlRewrite::METADATA]['category_id'] = $categoryId;
167+
} elseif (!$useCategories) {
168+
$filterData[UrlRewrite::METADATA]['category_id'] = '';
162169
}
170+
163171
$rewrite = $this->urlFinder->findOneByData($filterData);
172+
164173
if ($rewrite) {
165174
$requestPath = $rewrite->getRequestPath();
166175
$product->setRequestPath($requestPath);
@@ -194,6 +203,8 @@ public function getUrl(\Magento\Catalog\Model\Product $product, $params = [])
194203
$routeParams['_query'] = [];
195204
}
196205

197-
return $this->getUrlInstance()->setScope($storeId)->getUrl($routePath, $routeParams);
206+
$url = $this->urlFactory->create()->setScope($storeId);
207+
208+
return $url->getUrl($routePath, $routeParams);
198209
}
199210
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,11 @@ protected function _addUrlRewrite()
14221422
['cu' => $this->getTable('catalog_url_rewrite_product_category')],
14231423
'u.url_rewrite_id=cu.url_rewrite_id'
14241424
)->where('cu.category_id IN (?)', $this->_urlRewriteCategory);
1425+
} else {
1426+
$select->joinLeft(
1427+
['cu' => $this->getTable('catalog_url_rewrite_product_category')],
1428+
'u.url_rewrite_id=cu.url_rewrite_id'
1429+
)->where('cu.url_rewrite_id IS NULL');
14251430
}
14261431

14271432
// more priority is data with category id

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);

0 commit comments

Comments
 (0)