Skip to content
Snippets Groups Projects
Commit b1007444 authored by Maxim Medinskiy's avatar Maxim Medinskiy
Browse files

MAGETWO-43869: The "Header contains invalid attribute(s)..." message appears...

MAGETWO-43869: The "Header contains invalid attribute(s)..." message appears wher user tries to import customers
parent 098d3ff5
Branches
No related merge requests found
......@@ -5,6 +5,7 @@
*/
namespace Magento\CustomerImportExport\Model\Import;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
/**
......@@ -135,25 +136,25 @@ class Customer extends AbstractCustomer
/**
* Customer fields in file
*/
public $customerFields = [
'group_id',
'store_id',
'updated_at',
'created_at',
'created_in',
'prefix',
'firstname',
'middlename',
'lastname',
'suffix',
'dob',
protected $customerFields = [
CustomerInterface::GROUP_ID,
CustomerInterface::STORE_ID,
CustomerInterface::UPDATED_AT,
CustomerInterface::CREATED_AT,
CustomerInterface::CREATED_IN,
CustomerInterface::PREFIX,
CustomerInterface::FIRSTNAME,
CustomerInterface::MIDDLENAME,
CustomerInterface::LASTNAME,
CustomerInterface::SUFFIX,
CustomerInterface::DOB,
'password_hash',
'taxvat',
'confirmation',
'gender',
CustomerInterface::TAXVAT,
CustomerInterface::CONFIRMATION,
CustomerInterface::GENDER,
'rp_token',
'rp_token_created_at',
];
];
/**
* @param \Magento\Framework\Stdlib\StringUtils $string
......@@ -237,11 +238,6 @@ class Customer extends AbstractCustomer
$this->_initStores(true)->_initAttributes();
$this->validColumnNames = array_merge(
$this->validColumnNames,
$this->customerFields
);
$this->_customerModel = $customerFactory->create();
/** @var $customerResource \Magento\Customer\Model\ResourceModel\Customer */
$customerResource = $this->_customerModel->getResource();
......@@ -562,4 +558,17 @@ class Customer extends AbstractCustomer
{
return $this->_entityTable;
}
/**
* @inheritDoc
*/
public function getValidColumnNames()
{
$this->validColumnNames = array_merge(
$this->validColumnNames,
$this->customerFields
);
return $this->validColumnNames;
}
}
......@@ -224,13 +224,6 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
}
$this->_initAddressAttributes();
$this->validColumnNames = array_merge(
$this->validColumnNames,
$this->_customerAttributes,
$this->_addressAttributes,
$this->_customerEntity->customerFields
);
// next customer id
if (isset($data['next_customer_id'])) {
$this->_nextCustomerId = $data['next_customer_id'];
......@@ -489,4 +482,19 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
return parent::_prepareRowForDb($rowData);
}
/**
* @inheritDoc
*/
public function getValidColumnNames()
{
$this->validColumnNames = array_merge(
$this->validColumnNames,
$this->_customerAttributes,
$this->_addressAttributes,
$this->_customerEntity->customerFields
);
return $this->validColumnNames;
}
}
......@@ -792,7 +792,7 @@ abstract class AbstractEntity
$emptyHeaderColumns[] = $columnNumber;
} elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) {
$invalidColumns[] = $columnName;
} elseif ($this->needColumnCheck && !in_array($columnName, $this->validColumnNames)) {
} elseif ($this->needColumnCheck && !in_array($columnName, $this->getValidColumnNames())) {
$invalidAttributes[] = $columnName;
}
}
......@@ -854,4 +854,14 @@ abstract class AbstractEntity
$this->countItemsDeleted = count($deleted);
return $this;
}
/**
* Retrieve valid column names
*
* @return array
*/
public function getValidColumnNames()
{
return $this->validColumnNames;
}
}
......@@ -763,7 +763,7 @@ abstract class AbstractEntity
$emptyHeaderColumns[] = $columnNumber;
} elseif (!preg_match('/^[a-z][a-z0-9_]*$/', $columnName)) {
$invalidColumns[] = $columnName;
} elseif ($this->needColumnCheck && !in_array($columnName, $this->validColumnNames)) {
} elseif ($this->needColumnCheck && !in_array($columnName, $this->getValidColumnNames())) {
$invalidAttributes[] = $columnName;
}
}
......@@ -818,4 +818,14 @@ abstract class AbstractEntity
{
return $this->countItemsDeleted;
}
/**
* Retrieve valid column names
*
* @return array
*/
public function getValidColumnNames()
{
return $this->validColumnNames;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment