Skip to content

Commit 621bf09

Browse files
committed
Merge branch 'develop' into MAGETWO-61018
2 parents b7d599c + 3140ec6 commit 621bf09

File tree

237 files changed

+8766
-1743
lines changed

Some content is hidden

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

237 files changed

+8766
-1743
lines changed

Diff for: app/code/Magento/Backend/Block/Template.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,12 @@ public function getFormKey()
7070
*
7171
* @param string $moduleName Full module name
7272
* @return boolean
73+
* @deprecated
74+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7375
*/
7476
public function isOutputEnabled($moduleName = null)
7577
{
76-
if ($moduleName === null) {
77-
$moduleName = $this->getModuleName();
78-
}
79-
80-
return !$this->_scopeConfig->isSetFlag(
81-
'advanced/modules_disable_output/' . $moduleName,
82-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
83-
);
78+
return true;
8479
}
8580

8681
/**

Diff for: app/code/Magento/Backend/etc/adminhtml/system.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<tab id="advanced" translate="label" sortOrder="999999">
1717
<label>Advanced</label>
1818
</tab>
19-
<section id="advanced" translate="label" type="text" sortOrder="910" showInDefault="1" showInWebsite="1" showInStore="1">
19+
<section id="advanced" translate="label" type="text" sortOrder="910" showInDefault="0" showInWebsite="0" showInStore="0">
2020
<label>Advanced</label>
2121
<tab>advanced</tab>
2222
<resource>Magento_Backend::advanced</resource>

Diff for: app/code/Magento/Catalog/Model/Product/Price/BasePriceStorage.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ private function retrieveValidPrices(array $prices)
210210
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
211211
$this->validationResult->addFailedItem(
212212
$id,
213-
__('Requested store is not found.')
213+
__(
214+
'Requested store is not found. Row ID: SKU = %SKU, Store ID: %storeId.',
215+
['SKU' => $price->getSku(), 'storeId' => $price->getStoreId()]
216+
),
217+
['SKU' => $price->getSku(), 'storeId' => $price->getStoreId()]
214218
);
215219
}
216220
}

Diff for: app/code/Magento/Catalog/Model/Product/Price/CostStorage.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,22 @@ private function retrieveValidPrices(array $prices)
190190
$this->validationResult->addFailedItem(
191191
$id,
192192
__(
193-
'Invalid attribute %fieldName = %fieldValue.',
194-
['fieldName' => '%fieldName', 'fieldValue' => '%fieldValue']
193+
'Invalid attribute Cost = %cost. Row ID: SKU = %SKU, Store ID: %storeId.',
194+
['cost' => $price->getCost(), 'SKU' => $price->getSku(), 'storeId' => $price->getStoreId()]
195195
),
196-
['fieldName' => 'Cost', 'fieldValue' => $price->getCost()]
196+
['cost' => $price->getCost(), 'SKU' => $price->getSku(), 'storeId' => $price->getStoreId()]
197197
);
198198
}
199199
try {
200200
$this->storeRepository->getById($price->getStoreId());
201201
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
202202
$this->validationResult->addFailedItem(
203203
$id,
204-
__('Requested store is not found.')
204+
__(
205+
'Requested store is not found. Row ID: SKU = %SKU, Store ID: %storeId.',
206+
['SKU' => $price->getSku(), 'storeId' => $price->getStoreId()]
207+
),
208+
['SKU' => $price->getSku(), 'storeId' => $price->getStoreId()]
205209
);
206210
}
207211
}

Diff for: app/code/Magento/Catalog/Model/Product/Price/InvalidSkuChecker.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,20 @@ public function __construct(
3434
public function retrieveInvalidSkuList(array $skus, array $allowedProductTypes, $allowedPriceTypeValue = false)
3535
{
3636
$idsBySku = $this->productIdLocator->retrieveProductIdsBySkus($skus);
37-
$skuDiff = array_diff($skus, array_keys($idsBySku));
37+
$existingSkus = array_keys($idsBySku);
38+
$skuDiff = array_udiff(
39+
$skus,
40+
$existingSkus,
41+
'strcasecmp'
42+
);
3843

3944
foreach ($idsBySku as $sku => $ids) {
4045
foreach ($ids as $type) {
4146
$valueTypeIsAllowed = false;
4247

4348
if ($allowedPriceTypeValue
4449
&& $type == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE
45-
&& $this->productRepository->get($sku)->getPriceType() != $allowedProductTypes
50+
&& $this->productRepository->get($sku)->getPriceType() != $allowedPriceTypeValue
4651
) {
4752
$valueTypeIsAllowed = true;
4853
}

Diff for: app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php

+74-21
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,47 @@ private function retrieveValidPrices(array $prices)
143143
$this->validationResult->addFailedItem(
144144
$key,
145145
__(
146-
'Requested product doesn\'t exist: %sku',
147-
['sku' => '%sku']
146+
'Requested product doesn\'t exist. '
147+
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.',
148+
[
149+
'SKU' => $price->getSku(),
150+
'storeId' => $price->getStoreId(),
151+
'priceFrom' => $price->getPriceFrom(),
152+
'priceTo' => $price->getPriceTo()
153+
]
148154
),
149-
['sku' => $price->getSku()]
155+
[
156+
'SKU' => $price->getSku(),
157+
'storeId' => $price->getStoreId(),
158+
'priceFrom' => $price->getPriceFrom(),
159+
'priceTo' => $price->getPriceTo()
160+
]
150161
);
151162
}
152-
$this->checkPrice($price->getPrice(), $key);
153-
$this->checkDate($price->getPriceFrom(), 'Price From', $key);
154-
$this->checkDate($price->getPriceTo(), 'Price To', $key);
163+
$this->checkPrice($price, $key);
164+
$this->checkDate($price, $price->getPriceFrom(), 'Price From', $key);
165+
$this->checkDate($price, $price->getPriceTo(), 'Price To', $key);
155166
try {
156167
$this->storeRepository->getById($price->getStoreId());
157168
} catch (NoSuchEntityException $e) {
158169
$this->validationResult->addFailedItem(
159170
$key,
160-
__('Requested store is not found.')
171+
__(
172+
'Requested store is not found. '
173+
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.',
174+
[
175+
'SKU' => $price->getSku(),
176+
'storeId' => $price->getStoreId(),
177+
'priceFrom' => $price->getPriceFrom(),
178+
'priceTo' => $price->getPriceTo()
179+
]
180+
),
181+
[
182+
'SKU' => $price->getSku(),
183+
'storeId' => $price->getStoreId(),
184+
'priceFrom' => $price->getPriceFrom(),
185+
'priceTo' => $price->getPriceTo()
186+
]
161187
);
162188
}
163189
}
@@ -172,21 +198,35 @@ private function retrieveValidPrices(array $prices)
172198
/**
173199
* Check that date value is correct and add error to aggregator if it contains incorrect data.
174200
*
201+
* @param \Magento\Catalog\Api\Data\SpecialPriceInterface $price
175202
* @param string $value
176203
* @param string $label
177204
* @param int $key
178205
* @return void
179206
*/
180-
private function checkDate($value, $label, $key)
207+
private function checkDate(\Magento\Catalog\Api\Data\SpecialPriceInterface $price, $value, $label, $key)
181208
{
182209
if ($value && !$this->isCorrectDateValue($value)) {
183210
$this->validationResult->addFailedItem(
184211
$key,
185212
__(
186-
'Invalid attribute %fieldName = %fieldValue.',
187-
['fieldName' => '%fieldName', 'fieldValue' => '%fieldValue']
213+
'Invalid attribute %label = %priceTo. '
214+
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.',
215+
[
216+
'label' => $label,
217+
'SKU' => $price->getSku(),
218+
'storeId' => $price->getStoreId(),
219+
'priceFrom' => $price->getPriceFrom(),
220+
'priceTo' => $price->getPriceTo()
221+
]
188222
),
189-
['fieldName' => $label, 'fieldValue' => $value]
223+
[
224+
'label' => $label,
225+
'SKU' => $price->getSku(),
226+
'storeId' => $price->getStoreId(),
227+
'priceFrom' => $price->getPriceFrom(),
228+
'priceTo' => $price->getPriceTo()
229+
]
190230
);
191231
}
192232
}
@@ -195,35 +235,48 @@ private function checkDate($value, $label, $key)
195235
* Check that provided price value is not empty and not lower then zero and add error to aggregator if price
196236
* contains not valid data.
197237
*
198-
* @param float $price
238+
* @param \Magento\Catalog\Api\Data\SpecialPriceInterface $price
199239
* @param int $key
200240
* @return void
201241
*/
202-
private function checkPrice($price, $key)
242+
private function checkPrice(\Magento\Catalog\Api\Data\SpecialPriceInterface $price, $key)
203243
{
204-
if (null === $price || $price < 0) {
244+
if (null === $price->getPrice() || $price->getPrice() < 0) {
205245
$this->validationResult->addFailedItem(
206246
$key,
207247
__(
208-
'Invalid attribute %fieldName = %fieldValue.',
209-
['fieldName' => '%fieldName', 'fieldValue' => '%fieldValue']
248+
'Invalid attribute Price = %price. '
249+
. 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.',
250+
[
251+
'price' => $price->getPrice(),
252+
'SKU' => $price->getSku(),
253+
'storeId' => $price->getStoreId(),
254+
'priceFrom' => $price->getPriceFrom(),
255+
'priceTo' => $price->getPriceTo()
256+
]
210257
),
211-
['fieldName' => 'Price', 'fieldValue' => $price]
258+
[
259+
'price' => $price->getPrice(),
260+
'SKU' => $price->getSku(),
261+
'storeId' => $price->getStoreId(),
262+
'priceFrom' => $price->getPriceFrom(),
263+
'priceTo' => $price->getPriceTo()
264+
]
212265
);
213266
}
214267
}
215268

216269
/**
217270
* Retrieve SKU by product ID.
218271
*
219-
* @param int $id
272+
* @param int $productId
220273
* @param array $skus
221-
* @return int|null
274+
* @return string|null
222275
*/
223-
private function retrieveSkuById($id, array $skus)
276+
private function retrieveSkuById($productId, array $skus)
224277
{
225278
foreach ($this->productIdLocator->retrieveProductIdsBySkus($skus) as $sku => $ids) {
226-
if (false !== array_key_exists($id, $ids)) {
279+
if (isset($ids[$productId])) {
227280
return $sku;
228281
}
229282
}

Diff for: app/code/Magento/Catalog/Model/Product/Price/TierPriceStorage.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ private function retrieveAffectedPriceIds(array $prices)
259259
*
260260
* @param array $price
261261
* @param array $existingPrices
262-
* @return int|void
262+
* @return int|null
263263
*/
264264
private function retrievePriceId(array $price, array $existingPrices)
265265
{
@@ -275,6 +275,8 @@ private function retrievePriceId(array $price, array $existingPrices)
275275
return $existingPrice['value_id'];
276276
}
277277
}
278+
279+
return null;
278280
}
279281

280282
/**

Diff for: app/code/Magento/Catalog/Model/ProductIdLocator.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ public function retrieveProductIdsBySkus(array $skus)
9595
}
9696
}
9797

98-
return array_intersect_key($this->idsBySku, array_flip($skus));
98+
return array_intersect_ukey(
99+
$this->idsBySku,
100+
array_flip($skus),
101+
'strcasecmp'
102+
);
99103
}
100104
}

Diff for: app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Options/AjaxTest.php

-8
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ public function testToHtml()
5555
->getMock();
5656
$eventManager->expects($this->exactly(2))->method('dispatch')->will($this->returnValue(true));
5757

58-
$scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config::class)
59-
->setMethods(['getValue'])
60-
->disableOriginalConstructor()->getMock();
61-
$scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
62-
->will($this->returnValue(false));
63-
6458
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
6559
->setMethods(['setStoreId', 'load', 'getId', '__wakeup', '__sleep'])
6660
->getMock();
@@ -93,8 +87,6 @@ public function testToHtml()
9387

9488
$this->context->expects($this->once())->method('getEventManager')
9589
->will($this->returnValue($eventManager));
96-
$this->context->expects($this->once())->method('getScopeConfig')
97-
->will($this->returnValue($scopeConfig));
9890
$this->context->expects($this->once())->method('getLayout')
9991
->will($this->returnValue($layout));
10092
$this->context->expects($this->once())->method('getRequest')

Diff for: app/code/Magento/Catalog/Test/Unit/Block/Product/Widget/NewWidgetTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function setUp()
6363
false,
6464
false
6565
);
66-
$this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, ['getValue'], [], '', false, false);
66+
$this->scopeConfig = $this->getMock(\Magento\Framework\App\Config::class, [], [], '', false, false);
6767
$this->cacheState = $this->getMock(
6868
\Magento\Framework\App\Cache\State::class,
6969
['isEnabled'],
@@ -188,8 +188,6 @@ protected function generalGetProductCollection()
188188
{
189189
$this->eventManager->expects($this->exactly(2))->method('dispatch')
190190
->will($this->returnValue(true));
191-
$this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()
192-
->willReturn(false);
193191
$this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()
194192
->willReturn(false);
195193
$this->catalogConfig->expects($this->once())->method('getProductAttributes')

Diff for: app/code/Magento/Catalog/Test/Unit/Model/Product/Price/CostStorageTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function testUpdate()
252252
public function testUpdateWithNegativeCost()
253253
{
254254
$sku = 'sku_1';
255-
$this->costInterface->expects($this->exactly(3))->method('getSku')->willReturn($sku);
255+
$this->costInterface->expects($this->exactly(5))->method('getSku')->willReturn($sku);
256256
$this->invalidSkuChecker
257257
->expects($this->exactly(1))
258258
->method('retrieveInvalidSkuList')
@@ -267,7 +267,7 @@ public function testUpdateWithNegativeCost()
267267
->with(['attributeCode' => 'cost'])
268268
->willReturn($this->pricePersistence);
269269
$this->pricePersistence->expects($this->atLeastOnce())->method('update');
270-
$this->costInterface->expects($this->exactly(3))->method('getCost')->willReturn(-15);
270+
$this->costInterface->expects($this->exactly(4))->method('getCost')->willReturn(-15);
271271
$this->validationResult
272272
->expects($this->atLeastOnce())
273273
->method('getFailedItems');

0 commit comments

Comments
 (0)