Skip to content

Commit 68feb99

Browse files
Merge branch 'develop' of github.com:magento-folks/magento2ce into bugfix
2 parents 08d256b + a3adb88 commit 68feb99

File tree

15 files changed

+438
-42
lines changed

15 files changed

+438
-42
lines changed

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>

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
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sku,product_type,store_view_code,name,price,attribute_set_code,url_key
2+
simple1,simple,,"simple 1",25,Default,""
3+
simple2,simple,,"simple 2",34,Default,""
4+
simple3,simple,,"simple 3",58,Default,""

dev/tests/integration/testsuite/Magento/Framework/Composer/RemoveTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
*/
66
namespace Magento\Framework\Composer;
77

8-
use Magento\Framework\App\Filesystem\DirectoryList;
8+
use Magento\Composer\MagentoComposerApplication;
99

1010
class RemoveTest extends \PHPUnit_Framework_TestCase
1111
{
1212
public function testRemove()
1313
{
14-
$composerAppFactory = $this->getMock(
15-
\Magento\Framework\Composer\MagentoComposerApplicationFactory::class,
16-
[],
17-
[],
18-
'',
19-
false
20-
);
14+
$composerAppFactory = $this->getMockBuilder(MagentoComposerApplicationFactory::class)
15+
->disableOriginalConstructor()
16+
->getMock();
17+
$composerApp = $this->getMockBuilder(MagentoComposerApplication::class)
18+
->disableOriginalConstructor()
19+
->getMock();
2120

22-
$composerApp = $this->getMock(
23-
\Magento\Composer\MagentoComposerApplication::class,
24-
[],
25-
[],
26-
'',
27-
false
28-
);
29-
30-
$composerApp->expects($this->once())->method('runComposerCommand');
31-
32-
$composerAppFactory->expects($this->once())->method('create')->willReturn($composerApp);
21+
$composerApp->expects($this->once())
22+
->method('runComposerCommand')
23+
->with(
24+
[
25+
'command' => 'remove',
26+
'packages' => ['magento/package-a', 'magento/package-b'],
27+
'--no-update' => true,
28+
]
29+
);
30+
$composerAppFactory->expects($this->once())
31+
->method('create')
32+
->willReturn($composerApp);
3333

3434
$remove = new Remove($composerAppFactory);
3535
$remove->remove(['magento/package-a', 'magento/package-b']);

lib/internal/Magento/Framework/Composer/Remove.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public function remove(array $packages)
4545
return $composerApplication->runComposerCommand(
4646
[
4747
'command' => 'remove',
48-
'packages' => $packages
48+
'packages' => $packages,
49+
'--no-update' => true,
4950
]
5051
);
5152
}

0 commit comments

Comments
 (0)