Skip to content

Commit

Permalink
Merge pull request #681 from magento-nord/develop
Browse files Browse the repository at this point in the history
[NORD] sample data updated, migration tool included to CLI, bugfixes
  • Loading branch information
Bomko, Alex(abomko) committed Oct 7, 2015
2 parents 2e2785c + 6853185 commit 54b85e9
Show file tree
Hide file tree
Showing 82 changed files with 1,831 additions and 270 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"magento/module-media-storage": "1.0.0-beta"
},
"suggest": {
"magento/module-webapi": "1.0.0-beta"
"magento/module-webapi": "1.0.0-beta",
"magento/module-bundle-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"magento/module-ui": "self.version"
},
"suggest": {
"magento/module-cookie": "1.0.0-beta"
"magento/module-cookie": "1.0.0-beta",
"magento/module-catalog-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ public function prepareAttributesWithDefaultValueForSave(array $rowData, $withDe
foreach ($this->_getProductAttributes($rowData) as $attrCode => $attrParams) {
if (!$attrParams['is_static']) {
if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
$resultAttrs[$attrCode] = 'select' == $attrParams['type'] ? $attrParams['options'][strtolower(
$rowData[$attrCode]
)] : $rowData[$attrCode];
$resultAttrs[$attrCode] = in_array($attrParams['type'], ['select', 'boolean'])

This comment has been minimized.

Copy link
@ihor-sviziev

ihor-sviziev Oct 8, 2015

Contributor

Would be great to use third parameter in_array - true (strict mode)

? $attrParams['options'][strtolower($rowData[$attrCode])]
: $rowData[$attrCode];
if ('multiselect' == $attrParams['type']) {
$resultAttrs[$attrCode] = [];
foreach (explode(Product::PSEUDO_MULTI_LINE_SEPARATOR, $rowData[$attrCode]) as $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function isAttributeValid($attrCode, array $attrParams, array $rowData)
$valid = $this->numericValidation($attrCode, $attrParams['type']);
break;
case 'select':
case 'boolean':
case 'multiselect':
$values = explode(Product::PSEUDO_MULTI_LINE_SEPARATOR, $rowData[$attrCode]);
$valid = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,12 @@ protected function _moveFile($tmpPath, $destPath)
return false;
}
}

/**
* {@inheritdoc}
*/
protected function chmod($file)
{
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,40 +117,59 @@ protected function setUp()
'',
false
);

$entityAttributes = [[
'attribute_id' => 'attribute_id',
'attribute_set_name' => 'attributeSetName',
]];

$this->entityModel->expects($this->any())->method('getEntityTypeId')->willReturn(3);
$this->entityModel->expects($this->any())->method('getAttributeOptions')->willReturn(['option1', 'option2']);
$attrSetColFactory->expects($this->any())->method('create')->willReturn($attrSetCollection);
$attrSetCollection->expects($this->any())->method('setEntityTypeFilter')->willReturn([$attributeSet]);
$attrColFactory->expects($this->any())->method('create')->willReturn($attrCollection);
$attrCollection->expects($this->any())->method('setAttributeSetFilter')->willReturn([$attribute]);
$attributeSet->expects($this->any())->method('getId')->willReturn(1);
$attributeSet->expects($this->any())->method('getAttributeSetName')->willReturn('attribute_set_name');
$attribute->expects($this->any())->method('getAttributeCode')->willReturn('attr_code');
$attribute->expects($this->any())->method('getId')->willReturn('1');
$attribute->expects($this->any())->method('getIsVisible')->willReturn(true);
$attribute->expects($this->any())->method('getIsGlobal')->willReturn(true);
$attribute->expects($this->any())->method('getIsRequired')->willReturn(true);
$attribute->expects($this->any())->method('getIsUnique')->willReturn(true);
$attribute->expects($this->any())->method('getFrontendLabel')->willReturn('frontend_label');
$attribute->expects($this->any())->method('isStatic')->willReturn(true);
$attribute->expects($this->any())->method('getApplyTo')->willReturn(['simple']);
$attribute->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
$attribute->expects($this->any())->method('usesSource')->willReturn(true);
$attribute->expects($this->any())->method('getFrontendInput')->willReturn('multiselect');


$entityAttributes = [
[
'attribute_id' => 'attribute_id',
'attribute_set_name' => 'attributeSetName',
],
[
'attribute_id' => 'boolean_attribute',
'attribute_set_name' => 'attributeSetName'
]
];
$attribute1 = clone $attribute;
$attribute2 = clone $attribute;

$attribute1->expects($this->any())->method('getId')->willReturn('1');
$attribute1->expects($this->any())->method('getAttributeCode')->willReturn('attr_code');
$attribute1->expects($this->any())->method('getFrontendInput')->willReturn('multiselect');
$attribute1->expects($this->any())->method('isStatic')->willReturn(true);

$attribute2->expects($this->any())->method('getId')->willReturn('2');
$attribute2->expects($this->any())->method('getAttributeCode')->willReturn('boolean_attribute');
$attribute2->expects($this->any())->method('getFrontendInput')->willReturn('boolean');
$attribute2->expects($this->any())->method('isStatic')->willReturn(false);

$this->entityModel->expects($this->any())->method('getEntityTypeId')->willReturn(3);
$this->entityModel->expects($this->any())->method('getAttributeOptions')->willReturnOnConsecutiveCalls(
['option1', 'option2'],
['yes' => 1, 'no' => 0]
);
$attrSetColFactory->expects($this->any())->method('create')->willReturn($attrSetCollection);
$attrSetCollection->expects($this->any())->method('setEntityTypeFilter')->willReturn([$attributeSet]);
$attrColFactory->expects($this->any())->method('create')->willReturn($attrCollection);
$attrCollection->expects($this->any())->method('setAttributeSetFilter')->willReturn([$attribute1, $attribute2]);
$attributeSet->expects($this->any())->method('getId')->willReturn(1);
$attributeSet->expects($this->any())->method('getAttributeSetName')->willReturn('attribute_set_name');

$attrCollection
->expects($this->any())
->method('addFieldToFilter')
->with(
'main_table.attribute_id',
['in' => ['attribute_id']]
['in' => ['attribute_id', 'boolean_attribute']]
)
->willReturn([$attribute]);
->willReturn([$attribute1, $attribute2]);

$this->connection = $this->getMock(
'Magento\Framework\DB\Adapter\Pdo\Mysql',
Expand Down Expand Up @@ -343,6 +362,7 @@ public function addAttributeOptionDataProvider()
/**
* @param $object
* @param $property
* @return mixed
*/
protected function getPropertyValue(&$object, $property)
{
Expand All @@ -366,4 +386,14 @@ protected function setPropertyValue(&$object, $property, $value)
$reflectionProperty->setValue($object, $value);
return $object;
}

public function testPrepareAttributesWithDefaultValueForSave()
{
$rowData = [
'_attribute_set' => 'attributeSetName',
'boolean_attribute' => 'Yes'
];
$result = $this->simpleType->prepareAttributesWithDefaultValueForSave($rowData);
$this->assertEquals(['boolean_attribute' => 1], $result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ protected function setUp()
$this->validator->init($this->context);
}

public function testIsBooleanAttributeValid()
{
$this->context->expects($this->any())->method('getBehavior')
->willReturn(\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE);
$result = $this->validator->isAttributeValid(
'boolean_attribute',
[
'type' => 'boolean',
'apply_to' => ['simple'],
'is_required' => false
],
[
'product_type' => 'simple',
'boolean_attribute' => 'Yes'
]
);
$this->assertTrue($result);
}

public function testIsValidCorrect()
{
$value = ['product_type' => 'simple'];
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/CatalogRule/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"magento/framework": "1.0.0-beta"
},
"suggest": {
"magento/module-import-export": "1.0.0-beta"
"magento/module-import-export": "1.0.0-beta",
"magento/module-catalog-rule-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/CatalogUrlRewrite/etc/setup/events.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_save_after">
<observer name="process_url_rewrite_saving" instance="\Magento\CatalogUrlRewrite\Observer\ProductProcessUrlRewriteSavingObserver" method="execute"/>
</event>
</config>
3 changes: 3 additions & 0 deletions app/code/Magento/Cms/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"magento/module-media-storage": "1.0.0-beta",
"magento/framework": "1.0.0-beta"
},
"suggest": {
"magento/module-cms-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
Expand Down
6 changes: 4 additions & 2 deletions app/code/Magento/ConfigurableProduct/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"magento/module-ui": "self.version"
},
"suggest": {
"magento/module-webapi": "1.0.0-beta",
"magento/module-sales": "1.0.0-beta"
"magento/module-webapi": "1.0.0-beta",
"magento/module-sales": "1.0.0-beta",
"magento/module-configurable-sample-data": "Sample Data version:1.0.0-beta",
"magento/module-product-links-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Customer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"magento/module-quote": "1.0.0-beta"
},
"suggest": {
"magento/module-cookie": "1.0.0-beta"
"magento/module-cookie": "1.0.0-beta",
"magento/module-customer-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Deploy/Console/Command/SetModeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(ObjectManagerInterface $objectManager)
*/
protected function configure()
{
$description = 'Displays current application mode.';
$description = 'Set application mode.';

$this->setName('deploy:mode:set')
->setDescription($description)
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Downloadable/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"magento/module-quote": "1.0.0-beta",
"magento/framework": "1.0.0-beta"
},
"suggest": {
"magento/module-downloadable-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/GroupedProduct/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"magento/module-quote": "1.0.0-beta",
"magento/framework": "1.0.0-beta"
},
"suggest": {
"magento/module-grouped-product-sample-data": "Sample Data version:1.0.0-beta"
},
"type": "magento2-module",
"version": "1.0.0-beta",
"license": [
Expand Down
19 changes: 19 additions & 0 deletions app/code/Magento/ImportExport/Model/Export/Config/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@
*/
namespace Magento\ImportExport\Model\Export\Config;

use Magento\Framework\Module\Manager;
use Magento\Framework\App\Utility\Classes;

class Converter implements \Magento\Framework\Config\ConverterInterface
{
/**
* @var \Magento\Framework\Module\Manager
*/
protected $moduleManager;

/**
* @param Manager $moduleManager
*/
public function __construct(Manager $moduleManager)
{
$this->moduleManager = $moduleManager;
}

/**
* Convert dom node tree to array
*
Expand All @@ -25,6 +41,9 @@ public function convert($source)
$name = $attributes->getNamedItem('name')->nodeValue;
$label = $attributes->getNamedItem('label')->nodeValue;
$model = $attributes->getNamedItem('model')->nodeValue;
if (!$this->moduleManager->isOutputEnabled(Classes::getClassModuleName($model))) {
continue;
}
$entityAttributeFilterType = $attributes->getNamedItem('entityAttributeFilterType')->nodeValue;

$output['entities'][$name] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public function getAttributeOptions(\Magento\Eav\Model\Entity\Attribute\Abstract
foreach (is_array($option['value']) ? $option['value'] : [$option] as $innerOption) {
if (strlen($innerOption['value'])) {
// skip ' -- Please Select -- ' option
$options[$innerOption['value']] = $innerOption[$index];
$options[$innerOption['value']] = (string)$innerOption[$index];
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/ImportExport/Model/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,11 @@ public function getOperationResultMessages(ProcessingErrorAggregatorInterface $v
*/
public static function getAttributeType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute)
{
if ($attribute->usesSource() && in_array($attribute->getFrontendInput(), ['select', 'multiselect'])) {
return $attribute->getFrontendInput() == 'multiselect' ? 'multiselect' : 'select';
$frontendInput = $attribute->getFrontendInput();
if ($attribute->usesSource() && in_array($frontendInput, ['select', 'multiselect', 'boolean'])) {
return $frontendInput;
} elseif ($attribute->isStatic()) {
return $attribute->getFrontendInput() == 'date' ? 'datetime' : 'varchar';
return $frontendInput == 'date' ? 'datetime' : 'varchar';
} else {
return $attribute->getBackendType();
}
Expand Down
20 changes: 19 additions & 1 deletion app/code/Magento/ImportExport/Model/Import/Config/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,24 @@
*/
namespace Magento\ImportExport\Model\Import\Config;

use Magento\Framework\Module\Manager;
use Magento\Framework\App\Utility\Classes;

class Converter implements \Magento\Framework\Config\ConverterInterface
{
/**
* @var \Magento\Framework\Module\Manager
*/
protected $moduleManager;

/**
* @param Manager $moduleManager
*/
public function __construct(Manager $moduleManager)
{
$this->moduleManager = $moduleManager;
}

/**
* Convert dom node tree to array
*
Expand All @@ -26,7 +42,9 @@ public function convert($source)
$label = $attributes->getNamedItem('label')->nodeValue;
$behaviorModel = $attributes->getNamedItem('behaviorModel')->nodeValue;
$model = $attributes->getNamedItem('model')->nodeValue;

if (!$this->moduleManager->isOutputEnabled(Classes::getClassModuleName($model))) {
continue;
}
$output['entities'][$name] = [
'name' => $name,
'label' => $label,
Expand Down
Loading

0 comments on commit 54b85e9

Please sign in to comment.