Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into BUGS
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka committed Sep 26, 2016
2 parents e87751f + c5d04c6 commit c37e8ce
Show file tree
Hide file tree
Showing 17 changed files with 440 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function execute()
}

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

$block->setMessages($this->messageManager->getMessages(true));
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Categories,Categories
"Category is not available for requested store.","Category is not available for requested store."
"There was a category move error.","There was a category move error."
"There was a category move error. %1","There was a category move error. %1"
"You moved the category","You moved the category"
"You moved the category.","You moved the category."
"Attribute ""%1"" is required.","Attribute ""%1"" is required."
"You saved the category.","You saved the category."
"Something went wrong while saving the category.","Something went wrong while saving the category."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ public function export()
while (true) {
++$page;
$entityCollection = $this->_getEntityCollection(true);
$entityCollection->setOrder('has_options', 'asc');
$entityCollection->setOrder('entity_id', 'asc');
$entityCollection->setStoreId(Store::DEFAULT_STORE_ID);
$this->_prepareEntityCollection($entityCollection);
$this->paginateCollection($page, $this->getItemsPerPage());
Expand Down
21 changes: 15 additions & 6 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,10 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
/** @var array */
protected $productUrlSuffix = [];

/** @var array */
/**
* @var array
* @deprecated
*/
protected $productUrlKeys = [];

/**
Expand Down Expand Up @@ -1508,6 +1511,10 @@ protected function _saveProducts()
}
$rowScope = $this->getRowScope($rowData);

if (empty($rowData[self::URL_KEY])) {
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
}

$rowSku = $rowData[self::COL_SKU];

if (null === $rowSku) {
Expand Down Expand Up @@ -2562,12 +2569,14 @@ protected function getProductUrlSuffix($storeId = null)
protected function getUrlKey($rowData)
{
if (!empty($rowData[self::URL_KEY])) {
$this->productUrlKeys[$rowData[self::COL_SKU]] = $rowData[self::URL_KEY];
return $rowData[self::URL_KEY];
}

if (!empty($rowData[self::COL_NAME])) {
return $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
}
$urlKey = !empty($this->productUrlKeys[$rowData[self::COL_SKU]])
? $this->productUrlKeys[$rowData[self::COL_SKU]]
: $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
return $urlKey;

return '';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function testExportCountZeroBreakInternalCalls()
$this->product->expects($this->once())->method('_prepareEntityCollection')->with($this->abstractCollection);
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
$this->product->expects($this->once())->method('paginateCollection')->with($page, $itemsPerPage);
$this->abstractCollection->expects($this->once())->method('setOrder')->with('has_options', 'asc');
$this->abstractCollection->expects($this->once())->method('setOrder')->with('entity_id', 'asc');
$this->abstractCollection->expects($this->once())->method('setStoreId')->with(Store::DEFAULT_STORE_ID);

$this->abstractCollection->expects($this->once())->method('count')->willReturn(0);
Expand Down Expand Up @@ -434,7 +434,7 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
$this->product->expects($this->once())->method('_prepareEntityCollection')->with($this->abstractCollection);
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
$this->product->expects($this->once())->method('paginateCollection')->with($page, $itemsPerPage);
$this->abstractCollection->expects($this->once())->method('setOrder')->with('has_options', 'asc');
$this->abstractCollection->expects($this->once())->method('setOrder')->with('entity_id', 'asc');
$this->abstractCollection->expects($this->once())->method('setStoreId')->with(Store::DEFAULT_STORE_ID);

$this->abstractCollection->expects($this->once())->method('count')->willReturn(1);
Expand Down
76 changes: 76 additions & 0 deletions app/code/Magento/CatalogInventory/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CatalogInventory\Setup;

use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\Framework\Indexer\AbstractProcessor;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Store\Model\StoreManagerInterface;

/**
* Upgrade Data script
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface
{
/**
* @var StockConfigurationInterface
*/
private $configuration;

/**
* @var AbstractProcessor
*/
private $indexerProcessor;

/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* @param StockConfigurationInterface $configuration
* @param StoreManagerInterface $storeManager
* @param AbstractProcessor $indexerProcessor
*/
public function __construct(
StockConfigurationInterface $configuration,
StoreManagerInterface $storeManager,
AbstractProcessor $indexerProcessor
) {
$this->configuration = $configuration;
$this->storeManager = $storeManager;
$this->indexerProcessor = $indexerProcessor;
}

/**
* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.2') < 0) {
$this->upgradeCatalogInventoryStockItem($setup);
}
$setup->endSetup();
}

/**
* @param ModuleDataSetupInterface $setup
* @return void
*/
private function upgradeCatalogInventoryStockItem($setup)
{
$setup->getConnection()->update(
$setup->getTable('cataloginventory_stock_item'),
['website_id' => $this->configuration->getDefaultScopeId()],
['website_id = ?' => $this->storeManager->getWebsite()->getId()]
);
$this->indexerProcessor->getIndexer()->invalidate();
}
}
5 changes: 5 additions & 0 deletions app/code/Magento/CatalogInventory/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@
<type name="Magento\Catalog\Api\ProductRepositoryInterface">
<plugin name="catalogInventoryAroundSave" sortOrder="20" type="Magento\CatalogInventory\Model\Plugin\AroundProductRepositorySave"/>
</type>
<type name="Magento\CatalogInventory\Setup\UpgradeData">
<arguments>
<argument name="indexerProcessor" xsi:type="object">Magento\CatalogInventory\Model\Indexer\Stock\Processor</argument>
</arguments>
</type>
</config>
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogInventory/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_CatalogInventory" setup_version="2.0.1">
<module name="Magento_CatalogInventory" setup_version="2.0.2">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,42 @@ public function testExistingProductWithUrlKeys()
}
}

/**
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
* @magentoAppIsolation enabled
*/
public function testImportWithoutUrlKeys()
{
$products = [
'simple1' => 'simple-1',
'simple2' => 'simple-2',
'simple3' => 'simple-3'
];
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$source = $this->objectManager->create(
\Magento\ImportExport\Model\Import\Source\Csv::class,
[
'file' => __DIR__ . '/_files/products_to_import_without_url_keys.csv',
'directory' => $directory
]
);

$errors = $this->_model->setParameters(
['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND, 'entity' => 'catalog_product']
)
->setSource($source)
->validateData();

$this->assertTrue($errors->getErrorsCount() == 0);
$this->_model->importData();

$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
foreach ($products as $productSku => $productUrlKey) {
$this->assertEquals($productUrlKey, $productRepository->get($productSku)->getUrlKey());
}
}

/**
* @magentoAppIsolation enabled
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sku,product_type,store_view_code,name,price,attribute_set_code,url_key
simple1,simple,,"simple 1",25,Default,""
simple2,simple,,"simple 2",34,Default,""
simple3,simple,,"simple 3",58,Default,""
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
*/
namespace Magento\Framework\Composer;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Composer\MagentoComposerApplication;

class RemoveTest extends \PHPUnit_Framework_TestCase
{
public function testRemove()
{
$composerAppFactory = $this->getMock(
\Magento\Framework\Composer\MagentoComposerApplicationFactory::class,
[],
[],
'',
false
);
$composerAppFactory = $this->getMockBuilder(MagentoComposerApplicationFactory::class)
->disableOriginalConstructor()
->getMock();
$composerApp = $this->getMockBuilder(MagentoComposerApplication::class)
->disableOriginalConstructor()
->getMock();

$composerApp = $this->getMock(
\Magento\Composer\MagentoComposerApplication::class,
[],
[],
'',
false
);

$composerApp->expects($this->once())->method('runComposerCommand');

$composerAppFactory->expects($this->once())->method('create')->willReturn($composerApp);
$composerApp->expects($this->once())
->method('runComposerCommand')
->with(
[
'command' => 'remove',
'packages' => ['magento/package-a', 'magento/package-b'],
'--no-update' => true,
]
);
$composerAppFactory->expects($this->once())
->method('create')
->willReturn($composerApp);

$remove = new Remove($composerAppFactory);
$remove->remove(['magento/package-a', 'magento/package-b']);
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/Composer/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function remove(array $packages)
return $composerApplication->runComposerCommand(
[
'command' => 'remove',
'packages' => $packages
'packages' => $packages,
'--no-update' => true,
]
);
}
Expand Down
5 changes: 3 additions & 2 deletions setup/src/Magento/Setup/Module/I18n/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function getComponentName($componentType, $path)
*
* @param string $type
* @param array $value
* @return string
* @return string|null
* @throws \InvalidArgumentException
*/
public function buildPathToLocaleDirectoryByContext($type, $value)
Expand All @@ -111,6 +111,7 @@ public function buildPathToLocaleDirectoryByContext($type, $value)
default:
throw new \InvalidArgumentException(sprintf('Invalid context given: "%s".', $type));
}
return $path . '/' . self::LOCALE_DIRECTORY . '/';

return (null === $path) ? null : $path . '/' . self::LOCALE_DIRECTORY . '/';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ protected function _buildPackFilesData(Dictionary $dictionary)
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException($e->getMessage() . ' Row #' . ($key + 1) . '.');
}

if (null === $path) {
continue;
}

$filename = $path . $this->_locale . '.' . $this->_getFileExtension();
$files[$filename][$phrase->getPhrase()] = $phrase;
}
Expand Down
31 changes: 21 additions & 10 deletions setup/src/Magento/Setup/Test/Unit/Module/I18n/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetContextByPath($context, $path, $pathValues)
{
$this->componentRegistrar->expects($this->any())
->method('getPaths')
->will($this->returnValueMap($pathValues));
->willReturnMap($pathValues);
$this->context = new Context($this->componentRegistrar);
$this->assertEquals($context, $this->context->getContextByPath($path));
}
Expand Down Expand Up @@ -108,10 +108,8 @@ public function testBuildPathToLocaleDirectoryByContext($path, $context, $regist
$paths[$module[1]] = $module[2];
}
$this->componentRegistrar->expects($this->any())
->method('getPaths')
->with(ComponentRegistrar::MODULE)
->willReturn($paths);
$this->componentRegistrar->expects($this->any())->method('getPath')->will($this->returnValueMap($registrar));
->method('getPath')
->willReturnMap($registrar);
$this->context = new Context($this->componentRegistrar);
$this->assertEquals($path, $this->context->buildPathToLocaleDirectoryByContext($context[0], $context[1]));
}
Expand All @@ -127,7 +125,22 @@ public function dataProviderPathToLocaleDirectoryByContext()
[Context::CONTEXT_TYPE_MODULE, 'Magento_Module'],
[[ComponentRegistrar::MODULE, 'Magento_Module', BP . '/app/code/Magento/Module']]
],
['/i18n/', [Context::CONTEXT_TYPE_THEME, 'theme/test.phtml'], []],
[
BP . '/app/design/frontend/Magento/luma/i18n/',
[Context::CONTEXT_TYPE_THEME, 'frontend/Magento/luma'],
[[ComponentRegistrar::THEME, 'frontend/Magento/luma', BP . '/app/design/frontend/Magento/luma']]
],

[
null,
[Context::CONTEXT_TYPE_MODULE, 'Unregistered_Module'],
[[ComponentRegistrar::MODULE, 'Unregistered_Module', null]]
],
[
null,
[Context::CONTEXT_TYPE_THEME, 'frontend/Magento/unregistered'],
[[ComponentRegistrar::THEME, 'frontend/Magento/unregistered', null]]
],
[BP . '/lib/web/i18n/', [Context::CONTEXT_TYPE_LIB, 'lib/web/module/test.phtml'], []],
];
}
Expand All @@ -138,10 +151,8 @@ public function dataProviderPathToLocaleDirectoryByContext()
*/
public function testBuildPathToLocaleDirectoryByContextWithInvalidType()
{
$this->componentRegistrar->expects($this->any())
->method('getPaths')
->with(ComponentRegistrar::MODULE)
->willReturn(['module' => '/path/to/module']);
$this->componentRegistrar->expects($this->never())
->method('getPath');
$this->context = new Context($this->componentRegistrar);
$this->context->buildPathToLocaleDirectoryByContext('invalid_type', 'Magento_Module');
}
Expand Down
Loading

0 comments on commit c37e8ce

Please sign in to comment.