Skip to content

Commit b4bfdfc

Browse files
author
Sergey Semenov
committed
MAGETWO-44447: Customer gender is not updated after import
1 parent 6c3c600 commit b4bfdfc

File tree

1 file changed

+17
-10
lines changed
  • app/code/Magento/CustomerImportExport/Model/Import

1 file changed

+17
-10
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ class Customer extends AbstractCustomer
154154
CustomerInterface::GENDER,
155155
'rp_token',
156156
'rp_token_created_at',
157+
'failures_num',
158+
'first_failure',
159+
'lock_expires',
157160
];
158161

159162
/**
@@ -370,20 +373,24 @@ protected function _prepareDataForUpdate(array $rowData)
370373
if ($newCustomer && !strlen($value)) {
371374
continue;
372375
}
376+
377+
$attributeParameters = $this->_attributes[$attributeCode];
378+
if ('select' == $attributeParameters['type']) {
379+
$value = isset($attributeParameters['options'][strtolower($value)])
380+
? $attributeParameters['options'][strtolower($value)]
381+
: 0;
382+
} elseif ('datetime' == $attributeParameters['type'] && !empty($value)) {
383+
$value = (new \DateTime())->setTimestamp(strtotime($value));
384+
$value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
385+
}
386+
373387
if (!$this->_attributes[$attributeCode]['is_static']) {
374388
/** @var $attribute \Magento\Customer\Model\Attribute */
375389
$attribute = $this->_customerModel->getAttribute($attributeCode);
376390
$backendModel = $attribute->getBackendModel();
377-
$attributeParameters = $this->_attributes[$attributeCode];
378-
379-
if ('select' == $attributeParameters['type']) {
380-
$value = isset($attributeParameters['options'][strtolower($value)])
381-
? $attributeParameters['options'][strtolower($value)]
382-
: 0;
383-
} elseif ('datetime' == $attributeParameters['type']) {
384-
$value = (new \DateTime())->setTimestamp(strtotime($value));
385-
$value = $value->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
386-
} elseif ($backendModel) {
391+
if ($backendModel
392+
&& $attribute->getFrontendInput() != 'select'
393+
&& $attribute->getFrontendInput() != 'datetime') {
387394
$attribute->getBackend()->beforeSave($this->_customerModel->setData($attributeCode, $value));
388395
$value = $this->_customerModel->getData($attributeCode);
389396
}

0 commit comments

Comments
 (0)