Skip to content

Commit

Permalink
magento-engcom/import-export-improvements#30: Refactoring for readabi…
Browse files Browse the repository at this point in the history
…lity.
  • Loading branch information
pogster committed Jul 6, 2018
1 parent 0832e29 commit b4ce314
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/code/Magento/CustomerImportExport/Model/Import/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,18 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
if (in_array($attributeCode, $this->_ignoredAttributes)) {
continue;
}
if ($attributeParams['is_required']
&& ((!isset($rowData[$attributeCode]) && !$this->_getCustomerId($email, $website))
|| (isset($rowData[$attributeCode]) && '' === trim($rowData[$attributeCode])))) {

$isFieldRequired = $attributeParams['is_required'];
$isFieldNotSetAndCustomerDoesNotExist =
!isset($rowData[$attributeCode]) && !$this->_getCustomerId($email, $website);
$isFieldSetAndTrimmedValueIsEmpty
= isset($rowData[$attributeCode]) && '' === trim($rowData[$attributeCode]);

if ($isFieldRequired && ($isFieldNotSetAndCustomerDoesNotExist || $isFieldSetAndTrimmedValueIsEmpty)) {
$this->addRowError(self::ERROR_VALUE_IS_REQUIRED, $rowNumber, $attributeCode);
continue;
}

if (isset($rowData[$attributeCode]) && strlen($rowData[$attributeCode])) {
$this->isAttributeValid(
$attributeCode,
Expand Down

0 comments on commit b4ce314

Please sign in to comment.