Skip to content

Commit 46d9434

Browse files
author
Bohdan Korablov
committed
MAGETWO-71922: Error in Import Customers Main File with custom attribute.
1 parent 8e31029 commit 46d9434

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

app/code/Magento/CustomerImportExport/Model/Export/Address.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class Address extends \Magento\ImportExport\Model\Export\Entity\AbstractEav
3434
*/
3535
const COLUMN_COUNTRY_ID = 'country_id';
3636

37+
/**
38+
* Name of region id column
39+
*/
40+
const COLUMN_REGION_ID = 'region_id';
41+
3742
/**#@+
3843
* Particular columns that contains of customer default addresses
3944
*/
@@ -255,6 +260,7 @@ public function exportItem($item)
255260
$row[self::COLUMN_ADDRESS_ID] = $item['entity_id'];
256261
$row[self::COLUMN_EMAIL] = $customer['email'];
257262
$row[self::COLUMN_WEBSITE] = $this->_websiteIdToCode[$customer['website_id']];
263+
$row[self::COLUMN_REGION_ID] = $item->getRegionId();
258264

259265
$this->getWriter()->writeRow($row);
260266
}

app/code/Magento/CustomerImportExport/Model/Import/Address.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ protected function _mergeEntityAttributes(array $newAttributes, array $attribute
486486
*/
487487
protected function _prepareDataForUpdate(array $rowData)
488488
{
489-
$multiSeparator = $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR];
489+
$multiSeparator = isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR])
490+
? $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]
491+
: Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
490492
$email = strtolower($rowData[self::COLUMN_EMAIL]);
491493
$customerId = $this->_getCustomerId($email, $rowData[self::COLUMN_WEBSITE]);
492494
// entity table data
@@ -738,9 +740,9 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
738740
continue;
739741
}
740742
if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) {
741-
$multiSeparator = isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]) ?
742-
$this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR] :
743-
Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
743+
$multiSeparator = isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR])
744+
? $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]
745+
: Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
744746
$this->isAttributeValid(
745747
$attributeCode,
746748
$attributeParams,

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ protected function _getNextEntityId()
339339
*/
340340
protected function _prepareDataForUpdate(array $rowData)
341341
{
342-
$multiSeparator = $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR];
342+
$multiSeparator = isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR])
343+
? $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]
344+
: Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
343345
$entitiesToCreate = [];
344346
$entitiesToUpdate = [];
345347
$attributesToSave = [];
@@ -546,7 +548,9 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
546548
$attributeParams,
547549
$rowData,
548550
$rowNumber,
549-
$this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]
551+
isset($this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR])
552+
? $this->_parameters[Import::FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR]
553+
: Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
550554
);
551555
} elseif ($attributeParams['is_required'] && !$this->_getCustomerId($email, $website)) {
552556
$this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNumber, $attributeCode);

app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ protected function _addAttributeValuesToRow(\Magento\Framework\Model\AbstractMod
289289
* @param string $attributeCode An attribute code
290290
* @return bool Returns true if attribute is multiselect type
291291
*/
292-
private function isMultiselect($attributeCode) {
292+
private function isMultiselect($attributeCode)
293+
{
293294
return isset($this->_attributeTypes[$attributeCode])
294295
&& $this->_attributeTypes[$attributeCode] === 'multiselect';
295296
}
@@ -303,11 +304,8 @@ private function isMultiselect($attributeCode) {
303304
*/
304305
private function getAttributeValueById($attributeCode, $valueId)
305306
{
306-
if (isset(
307-
$this->_attributeValues[$attributeCode]
308-
) && isset(
309-
$this->_attributeValues[$attributeCode][$valueId]
310-
)
307+
if (isset($this->_attributeValues[$attributeCode])
308+
&& isset($this->_attributeValues[$attributeCode][$valueId])
311309
) {
312310
return $this->_attributeValues[$attributeCode][$valueId];
313311
}

0 commit comments

Comments
 (0)