Skip to content

Commit d46494b

Browse files
committed
MAGETWO-56063: After upgrading from 2.0.7 to 2.1, editing a category gives a 500 error
Merge remote-tracking branch 'mainline/develop' into MAGETWO-56063-upgrade-from-2.0.7-to-2.1.0
2 parents 8693a81 + 2842e92 commit d46494b

File tree

224 files changed

+11189
-1156
lines changed

Some content is hidden

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

224 files changed

+11189
-1156
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
<resource>Magento_Config::config_general</resource>
199199
<group id="country" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
200200
<label>Country Options</label>
201-
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
201+
<field id="allow" translate="label" type="multiselect" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
202202
<label>Allow Countries</label>
203203
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
204204
<can_be_empty>1</can_be_empty>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</requires>
3434
</field>
3535
<field id="braintree_cc_vault_active" translate="label" type="select" sortOrder="12" showInDefault="1" showInWebsite="1" showInStore="0">
36-
<label>Vault enabled</label>
36+
<label>Vault Enabled</label>
3737
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
3838
<config_path>payment/braintree_cc_vault/active</config_path>
3939
<requires>
@@ -155,7 +155,7 @@
155155
<comment>It is recommended to set this value to "PayPal" per store views.</comment>
156156
</field>
157157
<field id="braintree_paypal_vault_active" translate="label" type="select" sortOrder="21" showInDefault="1" showInWebsite="1" showInStore="0">
158-
<label>Vault enabled</label>
158+
<label>Vault Enabled</label>
159159
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
160160
<config_path>payment/braintree_paypal_vault/active</config_path>
161161
<requires>

app/code/Magento/Braintree/view/adminhtml/web/styles.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
.braintree-section .heading {display: inline-block; background: url("images/braintree_logo.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
7-
.braintree-section .button-container {display: inline-block; float: right;}
6+
.braintree-section .heading {background: url("images/braintree_logo.png") no-repeat 0 50% / 18rem auto; padding-left: 20rem;}
7+
.braintree-section .button-container {float: right;}
88
.braintree-section .config-alt {background: url("images/braintree_allinone.png") no-repeat scroll 0 0 / 100% auto; height: 28px; margin: 0.5rem 0 0; width: 230px;}

app/code/Magento/Catalog/view/frontend/templates/product/widget/link/link_inline.phtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
// @codingStandardsIgnoreFile
88
?>
9-
<div class="widget block block-product-link-inline">
9+
<span class="widget block block-product-link-inline">
1010
<a <?php /* @escapeNotVerified */ echo $block->getLinkAttributes() ?>><span><?php echo $block->escapeHtml($block->getLabel()) ?></span></a>
11-
</div>
11+
</span>

app/code/Magento/CatalogImportExport/Model/Import/Product.php

+39-1
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp)
13171317

13181318
$select = $this->_connection->select()->from(
13191319
$entityTable,
1320-
$this->getNewSkuFieldsForSelect()
1320+
array_merge($this->getNewSkuFieldsForSelect(), $this->getOldSkuFieldsForSelect())
13211321
)->where(
13221322
'sku IN (?)',
13231323
array_keys($entityRowsIn)
@@ -1330,10 +1330,45 @@ public function saveProductEntity(array $entityRowsIn, array $entityRowsUp)
13301330
$this->skuProcessor->setNewSkuData($sku, $key, $value);
13311331
}
13321332
}
1333+
1334+
$this->updateOldSku($newProducts);
13331335
}
1336+
13341337
return $this;
13351338
}
13361339

1340+
/**
1341+
* Return additional data, needed to select.
1342+
* @return array
1343+
*/
1344+
private function getOldSkuFieldsForSelect()
1345+
{
1346+
return ['type_id', 'attribute_set_id'];
1347+
}
1348+
1349+
/**
1350+
* Adds newly created products to _oldSku
1351+
* @param array $newProducts
1352+
* @return void
1353+
*/
1354+
private function updateOldSku(array $newProducts)
1355+
{
1356+
$oldSkus = [];
1357+
foreach ($newProducts as $info) {
1358+
$typeId = $info['type_id'];
1359+
$sku = $info['sku'];
1360+
$oldSkus[$sku] = [
1361+
'type_id' => $typeId,
1362+
'attr_set_id' => $info['attribute_set_id'],
1363+
$this->getProductIdentifierField() => $info[$this->getProductIdentifierField()],
1364+
'supported_type' => isset($this->_productTypeModels[$typeId]),
1365+
$this->getProductEntityLinkField() => $info[$this->getProductEntityLinkField()],
1366+
];
1367+
}
1368+
1369+
$this->_oldSku = array_replace($this->_oldSku, $oldSkus);
1370+
}
1371+
13371372
/**
13381373
* Get new SKU fields for select
13391374
*
@@ -1718,6 +1753,7 @@ protected function _saveProducts()
17181753
['adapter' => $this, 'bunch' => $bunch]
17191754
);
17201755
}
1756+
17211757
return $this;
17221758
}
17231759

@@ -2452,6 +2488,7 @@ protected function _saveValidatedBunches()
24522488
{
24532489
$source = $this->_getSource();
24542490
$source->rewind();
2491+
24552492
while ($source->valid()) {
24562493
try {
24572494
$rowData = $source->current();
@@ -2465,6 +2502,7 @@ protected function _saveValidatedBunches()
24652502
$rowData = $this->_customFieldsMapping($rowData);
24662503

24672504
$this->validateRow($rowData, $source->key());
2505+
24682506
$source->next();
24692507
}
24702508
$this->checkUrlKeyDuplicates();

app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php

+9
Original file line numberDiff line numberDiff line change
@@ -567,4 +567,13 @@ protected function getProductEntityLinkField()
567567
}
568568
return $this->productEntityLinkField;
569569
}
570+
571+
/**
572+
* Clean cached values
573+
*/
574+
public function __destruct()
575+
{
576+
self::$attributeCodeToId = [];
577+
self::$commonAttributesCache = [];
578+
}
570579
}

app/code/Magento/Cms/view/frontend/templates/widget/link/link_inline.phtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66
?>
7-
<div class="widget block block-cms-link-inline">
7+
<span class="widget block block-cms-link-inline">
88
<a <?php /* @escapeNotVerified */ echo $block->getLinkAttributes() ?>>
99
<span><?php echo $block->escapeHtml($block->getLabel()) ?></span>
1010
</a>
11-
</div>
11+
</span>

app/code/Magento/ConfigurableProduct/Model/Product/VariationHandler.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,14 @@ protected function fillSimpleProductData(
148148
\Magento\Catalog\Model\Product $parentProduct,
149149
$postData
150150
) {
151+
$typeId = isset($postData['weight']) && !empty($postData['weight'])
152+
? ProductType::TYPE_SIMPLE
153+
: ProductType::TYPE_VIRTUAL;
154+
151155
$product->setStoreId(
152156
\Magento\Store\Model\Store::DEFAULT_STORE_ID
153157
)->setTypeId(
154-
$postData['weight'] ? ProductType::TYPE_SIMPLE : ProductType::TYPE_VIRTUAL
158+
$typeId
155159
)->setAttributeSetId(
156160
$parentProduct->getNewVariationsAttributeSetId()
157161
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Pricing\Render;
7+
8+
use Magento\Catalog\Pricing\Price\FinalPrice;
9+
use Magento\Catalog\Pricing\Price\RegularPrice;
10+
use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface;
11+
use Magento\Framework\Pricing\Price\PriceInterface;
12+
use Magento\Framework\Pricing\Render\RendererPool;
13+
use Magento\Framework\Pricing\SaleableInterface;
14+
use Magento\Framework\View\Element\Template\Context;
15+
16+
class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox
17+
{
18+
/**
19+
* @var ConfigurableOptionsProviderInterface
20+
*/
21+
private $configurableOptionsProvider;
22+
23+
/**
24+
* @param Context $context
25+
* @param SaleableInterface $saleableItem
26+
* @param PriceInterface $price
27+
* @param RendererPool $rendererPool
28+
* @param ConfigurableOptionsProviderInterface $configurableOptionsProvider
29+
* @param array $data
30+
*/
31+
public function __construct(
32+
Context $context,
33+
SaleableInterface $saleableItem,
34+
PriceInterface $price,
35+
RendererPool $rendererPool,
36+
ConfigurableOptionsProviderInterface $configurableOptionsProvider,
37+
array $data = []
38+
) {
39+
$this->configurableOptionsProvider = $configurableOptionsProvider;
40+
parent::__construct($context, $saleableItem, $price, $rendererPool, $data);
41+
}
42+
43+
/**
44+
* Define if the special price should be shown
45+
*
46+
* @return bool
47+
*/
48+
public function hasSpecialPrice()
49+
{
50+
$product = $this->getSaleableItem();
51+
foreach ($this->configurableOptionsProvider->getProducts($product) as $subProduct) {
52+
$regularPrice = $subProduct->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getValue();
53+
$finalPrice = $subProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue();
54+
if ($finalPrice < $regularPrice) {
55+
return true;
56+
}
57+
}
58+
return false;
59+
}
60+
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/VariationHandlerTest.php

+44-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\ConfigurableProduct\Test\Unit\Model\Product;
1010

11+
use Magento\Catalog\Model\Product\Type;
1112
use Magento\ConfigurableProduct\Model\Product\VariationHandler;
1213

1314
/**
@@ -162,23 +163,30 @@ public function testPrepareAttributeSet()
162163

163164
/**
164165
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
166+
* @dataProvider dataProviderTestGenerateSimpleProducts
167+
* @param int|string|null $weight
168+
* @param string $typeId
165169
*/
166-
public function testGenerateSimpleProducts()
170+
public function testGenerateSimpleProducts($weight, $typeId)
167171
{
168172
$productsData = [
169-
6 =>
170-
[
171-
'image' => 'image.jpg',
172-
'name' => 'config-red',
173-
'configurable_attribute' => '{"new_attr":"6"}',
174-
'sku' => 'config-red',
175-
'quantity_and_stock_status' =>
176-
[
177-
'qty' => '',
178-
],
179-
'weight' => '333',
180-
]
173+
[
174+
'image' => 'image.jpg',
175+
'name' => 'config-red',
176+
'configurable_attribute' => '{"new_attr":"6"}',
177+
'sku' => 'config-red',
178+
'quantity_and_stock_status' =>
179+
[
180+
'qty' => '',
181+
],
182+
]
181183
];
184+
185+
// Do not add 'weight' attribute if it's value is null!
186+
if ($weight !== null) {
187+
$productsData[0]['weight'] = $weight;
188+
}
189+
182190
$stockData = [
183191
'manage_stock' => '0',
184192
'use_config_enable_qty_increments' => '1',
@@ -218,7 +226,7 @@ public function testGenerateSimpleProducts()
218226
)
219227
->disableOriginalConstructor()
220228
->getMock();
221-
$productTypeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type::class)
229+
$productTypeMock = $this->getMockBuilder(Type::class)
222230
->setMethods(['getSetAttributes'])
223231
->disableOriginalConstructor()
224232
->getMock();
@@ -236,7 +244,7 @@ public function testGenerateSimpleProducts()
236244
->willReturn('new_attr_set_id');
237245
$this->productFactoryMock->expects($this->once())->method('create')->willReturn($newSimpleProductMock);
238246
$newSimpleProductMock->expects($this->once())->method('setStoreId')->with(0)->willReturnSelf();
239-
$newSimpleProductMock->expects($this->once())->method('setTypeId')->with('simple')->willReturnSelf();
247+
$newSimpleProductMock->expects($this->once())->method('setTypeId')->with($typeId)->willReturnSelf();
240248
$newSimpleProductMock->expects($this->once())
241249
->method('setAttributeSetId')
242250
->with('new_attr_set_id')
@@ -265,6 +273,27 @@ public function testGenerateSimpleProducts()
265273
$this->assertEquals(['product_id'], $this->model->generateSimpleProducts($parentProductMock, $productsData));
266274
}
267275

276+
/**
277+
* @return array
278+
*/
279+
public function dataProviderTestGenerateSimpleProducts()
280+
{
281+
return [
282+
[
283+
'weight' => 333,
284+
'type_id' => Type::TYPE_SIMPLE,
285+
],
286+
[
287+
'weight' => '',
288+
'type_id' => Type::TYPE_VIRTUAL,
289+
],
290+
[
291+
'weight' => null,
292+
'type_id' => Type::TYPE_VIRTUAL,
293+
],
294+
];
295+
}
296+
268297
public function testProcessMediaGalleryWithImagesAndGallery()
269298
{
270299
$this->product->expects($this->atLeastOnce())->method('getMediaGallery')->with('images')->willReturn([]);

0 commit comments

Comments
 (0)