Skip to content

Commit 34eb8a0

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-54645
2 parents 81c5f5f + 73bf648 commit 34eb8a0

File tree

237 files changed

+11590
-1393
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

+11590
-1393
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories;
99
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
1010
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
11+
use Magento\Framework\App\CacheInterface;
1112
use Magento\Framework\DB\Helper as DbHelper;
1213
use Magento\Framework\UrlInterface;
1314
use Magento\Store\Model\Store;
@@ -112,4 +113,38 @@ public function testModifyMeta()
112113

113114
$this->assertArrayHasKey($groupCode, $this->getModel()->modifyMeta($meta));
114115
}
116+
117+
public function testModifyMetaWithCaching()
118+
{
119+
$this->arrayManagerMock->expects($this->exactly(2))
120+
->method('findPath')
121+
->willReturn(true);
122+
$cacheManager = $this->getMockBuilder(CacheInterface::class)
123+
->getMockForAbstractClass();
124+
$cacheManager->expects($this->once())
125+
->method('load')
126+
->with(Categories::CATEGORY_TREE_ID . '_');
127+
$cacheManager->expects($this->once())
128+
->method('save');
129+
130+
$modifier = $this->createModel();
131+
$cacheContextProperty = new \ReflectionProperty(
132+
Categories::class,
133+
'cacheManager'
134+
);
135+
$cacheContextProperty->setAccessible(true);
136+
$cacheContextProperty->setValue($modifier, $cacheManager);
137+
138+
$groupCode = 'test_group_code';
139+
$meta = [
140+
$groupCode => [
141+
'children' => [
142+
'category_ids' => [
143+
'sortOrder' => 10,
144+
],
145+
],
146+
],
147+
];
148+
$modifier->modifyMeta($meta);
149+
}
115150
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,25 @@
77

88
use Magento\Catalog\Model\Locator\LocatorInterface;
99
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\App\CacheInterface;
1012
use Magento\Framework\DB\Helper as DbHelper;
1113
use Magento\Catalog\Model\Category as CategoryModel;
1214
use Magento\Framework\UrlInterface;
1315
use Magento\Framework\Stdlib\ArrayManager;
1416

1517
/**
1618
* Data provider for categories field of product page
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1720
*/
1821
class Categories extends AbstractModifier
1922
{
23+
/**#@+
24+
* Category tree cache id
25+
*/
26+
const CATEGORY_TREE_ID = 'CATALOG_PRODUCT_CATEGORY_TREE';
27+
/**#@-*/
28+
2029
/**
2130
* @var CategoryCollectionFactory
2231
*/
@@ -29,6 +38,7 @@ class Categories extends AbstractModifier
2938

3039
/**
3140
* @var array
41+
* @deprecated
3242
*/
3343
protected $categoriesTrees = [];
3444

@@ -47,6 +57,11 @@ class Categories extends AbstractModifier
4757
*/
4858
protected $arrayManager;
4959

60+
/**
61+
* @var CacheInterface
62+
*/
63+
private $cacheManager;
64+
5065
/**
5166
* @param LocatorInterface $locator
5267
* @param CategoryCollectionFactory $categoryCollectionFactory
@@ -68,6 +83,21 @@ public function __construct(
6883
$this->arrayManager = $arrayManager;
6984
}
7085

86+
/**
87+
* Retrieve cache interface
88+
*
89+
* @return CacheInterface
90+
* @deprecated
91+
*/
92+
private function getCacheManager()
93+
{
94+
if (!$this->cacheManager) {
95+
$this->cacheManager = ObjectManager::getInstance()
96+
->get(CacheInterface::class);
97+
}
98+
return $this->cacheManager;
99+
}
100+
71101
/**
72102
* {@inheritdoc}
73103
*/
@@ -254,8 +284,9 @@ protected function customizeCategoriesField(array $meta)
254284
*/
255285
protected function getCategoriesTree($filter = null)
256286
{
257-
if (isset($this->categoriesTrees[$filter])) {
258-
return $this->categoriesTrees[$filter];
287+
$categoryTree = $this->getCacheManager()->load(self::CATEGORY_TREE_ID . '_' . $filter);
288+
if ($categoryTree) {
289+
return unserialize($categoryTree);
259290
}
260291

261292
$storeId = $this->locator->getStore()->getId();
@@ -307,9 +338,16 @@ protected function getCategoriesTree($filter = null)
307338
$categoryById[$category->getId()]['label'] = $category->getName();
308339
$categoryById[$category->getParentId()]['optgroup'][] = &$categoryById[$category->getId()];
309340
}
341+
342+
$this->getCacheManager()->save(
343+
serialize($categoryById[CategoryModel::TREE_ROOT_ID]['optgroup']),
344+
self::CATEGORY_TREE_ID . '_' . $filter,
345+
[
346+
\Magento\Catalog\Model\Category::CACHE_TAG,
347+
\Magento\Framework\App\Cache\Type\Block::CACHE_TAG
348+
]
349+
);
310350

311-
$this->categoriesTrees[$filter] = $categoryById[CategoryModel::TREE_ROOT_ID]['optgroup'];
312-
313-
return $this->categoriesTrees[$filter];
351+
return $categoryById[CategoryModel::TREE_ROOT_ID]['optgroup'];
314352
}
315353
}

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 39 additions & 1 deletion
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 5 additions & 1 deletion
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
);

0 commit comments

Comments
 (0)