Skip to content

Commit ba6c5c0

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into BUGS-Infra
2 parents 899e089 + 8931b9c commit ba6c5c0

File tree

18 files changed

+442
-46
lines changed

18 files changed

+442
-46
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function execute()
8080
}
8181

8282
if (!$error) {
83-
$this->messageManager->addSuccess(__('You moved the category'));
83+
$this->messageManager->addSuccess(__('You moved the category.'));
8484
}
8585

8686
$block->setMessages($this->messageManager->getMessages(true));

app/code/Magento/Catalog/i18n/en_US.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Categories,Categories
183183
"Category is not available for requested store.","Category is not available for requested store."
184184
"There was a category move error.","There was a category move error."
185185
"There was a category move error. %1","There was a category move error. %1"
186-
"You moved the category","You moved the category"
186+
"You moved the category.","You moved the category."
187187
"Attribute ""%1"" is required.","Attribute ""%1"" is required."
188188
"You saved the category.","You saved the category."
189189
"Something went wrong while saving the category.","Something went wrong while saving the category."

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ public function export()
817817
while (true) {
818818
++$page;
819819
$entityCollection = $this->_getEntityCollection(true);
820-
$entityCollection->setOrder('has_options', 'asc');
820+
$entityCollection->setOrder('entity_id', 'asc');
821821
$entityCollection->setStoreId(Store::DEFAULT_STORE_ID);
822822
$this->_prepareEntityCollection($entityCollection);
823823
$this->paginateCollection($page, $this->getItemsPerPage());

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,10 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
561561
/** @var array */
562562
protected $productUrlSuffix = [];
563563

564-
/** @var array */
564+
/**
565+
* @var array
566+
* @deprecated
567+
*/
565568
protected $productUrlKeys = [];
566569

567570
/**
@@ -1508,6 +1511,10 @@ protected function _saveProducts()
15081511
}
15091512
$rowScope = $this->getRowScope($rowData);
15101513

1514+
if (empty($rowData[self::URL_KEY])) {
1515+
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
1516+
}
1517+
15111518
$rowSku = $rowData[self::COL_SKU];
15121519

15131520
if (null === $rowSku) {
@@ -2562,12 +2569,14 @@ protected function getProductUrlSuffix($storeId = null)
25622569
protected function getUrlKey($rowData)
25632570
{
25642571
if (!empty($rowData[self::URL_KEY])) {
2565-
$this->productUrlKeys[$rowData[self::COL_SKU]] = $rowData[self::URL_KEY];
2572+
return $rowData[self::URL_KEY];
2573+
}
2574+
2575+
if (!empty($rowData[self::COL_NAME])) {
2576+
return $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
25662577
}
2567-
$urlKey = !empty($this->productUrlKeys[$rowData[self::COL_SKU]])
2568-
? $this->productUrlKeys[$rowData[self::COL_SKU]]
2569-
: $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
2570-
return $urlKey;
2578+
2579+
return '';
25712580
}
25722581

25732582
/**

app/code/Magento/CatalogImportExport/Test/Unit/Model/Export/ProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public function testExportCountZeroBreakInternalCalls()
403403
$this->product->expects($this->once())->method('_prepareEntityCollection')->with($this->abstractCollection);
404404
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
405405
$this->product->expects($this->once())->method('paginateCollection')->with($page, $itemsPerPage);
406-
$this->abstractCollection->expects($this->once())->method('setOrder')->with('has_options', 'asc');
406+
$this->abstractCollection->expects($this->once())->method('setOrder')->with('entity_id', 'asc');
407407
$this->abstractCollection->expects($this->once())->method('setStoreId')->with(Store::DEFAULT_STORE_ID);
408408

409409
$this->abstractCollection->expects($this->once())->method('count')->willReturn(0);
@@ -434,7 +434,7 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
434434
$this->product->expects($this->once())->method('_prepareEntityCollection')->with($this->abstractCollection);
435435
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
436436
$this->product->expects($this->once())->method('paginateCollection')->with($page, $itemsPerPage);
437-
$this->abstractCollection->expects($this->once())->method('setOrder')->with('has_options', 'asc');
437+
$this->abstractCollection->expects($this->once())->method('setOrder')->with('entity_id', 'asc');
438438
$this->abstractCollection->expects($this->once())->method('setStoreId')->with(Store::DEFAULT_STORE_ID);
439439

440440
$this->abstractCollection->expects($this->once())->method('count')->willReturn(1);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogInventory\Setup;
7+
8+
use Magento\CatalogInventory\Api\StockConfigurationInterface;
9+
use Magento\Framework\Indexer\AbstractProcessor;
10+
use Magento\Framework\Setup\UpgradeDataInterface;
11+
use Magento\Framework\Setup\ModuleContextInterface;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Store\Model\StoreManagerInterface;
14+
15+
/**
16+
* Upgrade Data script
17+
* @codeCoverageIgnore
18+
*/
19+
class UpgradeData implements UpgradeDataInterface
20+
{
21+
/**
22+
* @var StockConfigurationInterface
23+
*/
24+
private $configuration;
25+
26+
/**
27+
* @var AbstractProcessor
28+
*/
29+
private $indexerProcessor;
30+
31+
/**
32+
* @var StoreManagerInterface
33+
*/
34+
private $storeManager;
35+
36+
/**
37+
* @param StockConfigurationInterface $configuration
38+
* @param StoreManagerInterface $storeManager
39+
* @param AbstractProcessor $indexerProcessor
40+
*/
41+
public function __construct(
42+
StockConfigurationInterface $configuration,
43+
StoreManagerInterface $storeManager,
44+
AbstractProcessor $indexerProcessor
45+
) {
46+
$this->configuration = $configuration;
47+
$this->storeManager = $storeManager;
48+
$this->indexerProcessor = $indexerProcessor;
49+
}
50+
51+
/**
52+
* {@inheritdoc}
53+
*/
54+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
55+
{
56+
$setup->startSetup();
57+
if (version_compare($context->getVersion(), '2.0.2') < 0) {
58+
$this->upgradeCatalogInventoryStockItem($setup);
59+
}
60+
$setup->endSetup();
61+
}
62+
63+
/**
64+
* @param ModuleDataSetupInterface $setup
65+
* @return void
66+
*/
67+
private function upgradeCatalogInventoryStockItem($setup)
68+
{
69+
$setup->getConnection()->update(
70+
$setup->getTable('cataloginventory_stock_item'),
71+
['website_id' => $this->configuration->getDefaultScopeId()],
72+
['website_id = ?' => $this->storeManager->getWebsite()->getId()]
73+
);
74+
$this->indexerProcessor->getIndexer()->invalidate();
75+
}
76+
}

app/code/Magento/CatalogInventory/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@
7474
<type name="Magento\Catalog\Api\ProductRepositoryInterface">
7575
<plugin name="catalogInventoryAroundSave" sortOrder="20" type="Magento\CatalogInventory\Model\Plugin\AroundProductRepositorySave"/>
7676
</type>
77+
<type name="Magento\CatalogInventory\Setup\UpgradeData">
78+
<arguments>
79+
<argument name="indexerProcessor" xsi:type="object">Magento\CatalogInventory\Model\Indexer\Stock\Processor</argument>
80+
</arguments>
81+
</type>
7782
</config>

app/code/Magento/CatalogInventory/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_CatalogInventory" setup_version="2.0.1">
9+
<module name="Magento_CatalogInventory" setup_version="2.0.2">
1010
<sequence>
1111
<module name="Magento_Catalog"/>
1212
</sequence>

app/code/Magento/Cms/Ui/Component/DataProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ private function getAuthorizationInstance()
7373
*
7474
* @return array
7575
*/
76-
public function prepareMetadata() {
76+
public function prepareMetadata()
77+
{
7778
$metadata = [];
7879

7980
if (!$this->getAuthorizationInstance()->isAllowed('Magento_Cms::save')) {
@@ -95,4 +96,3 @@ public function prepareMetadata() {
9596
return $metadata;
9697
}
9798
}
98-

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,42 @@ public function testExistingProductWithUrlKeys()
12311231
}
12321232
}
12331233

1234+
/**
1235+
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
1236+
* @magentoAppIsolation enabled
1237+
*/
1238+
public function testImportWithoutUrlKeys()
1239+
{
1240+
$products = [
1241+
'simple1' => 'simple-1',
1242+
'simple2' => 'simple-2',
1243+
'simple3' => 'simple-3'
1244+
];
1245+
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
1246+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
1247+
$source = $this->objectManager->create(
1248+
\Magento\ImportExport\Model\Import\Source\Csv::class,
1249+
[
1250+
'file' => __DIR__ . '/_files/products_to_import_without_url_keys.csv',
1251+
'directory' => $directory
1252+
]
1253+
);
1254+
1255+
$errors = $this->_model->setParameters(
1256+
['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product']
1257+
)
1258+
->setSource($source)
1259+
->validateData();
1260+
1261+
$this->assertTrue($errors->getErrorsCount() == 0);
1262+
$this->_model->importData();
1263+
1264+
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
1265+
foreach ($products as $productSku => $productUrlKey) {
1266+
$this->assertEquals($productUrlKey, $productRepository->get($productSku)->getUrlKey());
1267+
}
1268+
}
1269+
12341270
/**
12351271
* @magentoAppIsolation enabled
12361272
*/

0 commit comments

Comments
 (0)