Skip to content

Commit 8afce66

Browse files
committed
ACP2E-2990: Customer "created_at" date Not Converted to store time zone upon export
- Fixed the CR comments.
1 parent 8f46ec1 commit 8afce66

File tree

2 files changed

+21
-12
lines changed
  • app/code/Magento/CustomerImportExport/Model/Export
  • dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export

2 files changed

+21
-12
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav
2929

3030
private const COLUMN_CREATED_AT = 'created_at';
3131

32+
private const COLUMN_UPDATED_AT = 'updated_at';
33+
3234
/**
3335
* A constant declaration for attribute collection name
3436
*/
@@ -160,13 +162,17 @@ public function exportItem($item)
160162
$row = $this->_addAttributeValuesToRow($item);
161163
$row[self::COLUMN_WEBSITE] = $this->_websiteIdToCode[$item->getWebsiteId()];
162164
$row[self::COLUMN_STORE] = $this->_storeIdToCode[$item->getStoreId()];
165+
163166
if (isset($row[self::COLUMN_CREATED_AT])) {
164-
$row[self::COLUMN_CREATED_AT] = $this->_localeDate->formatDate(
165-
$item->getCreatedAt(),
166-
\IntlDateFormatter::MEDIUM,
167-
true
168-
);
169-
$row[self::COLUMN_CREATED_AT] = (new \DateTime($row[self::COLUMN_CREATED_AT]))->format('Y-m-d H:i:s');
167+
$row[self::COLUMN_CREATED_AT] = $this->_localeDate
168+
->scopeDate(null, $item->getCreatedAt(), true)
169+
->format('Y-m-d H:i:s');
170+
}
171+
172+
if (isset($row[self::COLUMN_UPDATED_AT])) {
173+
$row[self::COLUMN_UPDATED_AT] = $this->_localeDate
174+
->scopeDate(null, $item->getUpdatedAt(), true)
175+
->format('Y-m-d H:i:s');
170176
}
171177

172178
$this->getWriter()->writeRow($row);

dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,15 @@ private function checkExportData(array $lines, array $expectedAttributes): void
161161
$customers = $this->objectManager->create(CustomerCollection::class);
162162
foreach ($customers as $customer) {
163163
$data = $this->processCustomerData($customer, $expectedAttributes);
164-
$data['created_at'] = $this->localeDate->formatDate(
165-
$data['created_at'],
166-
\IntlDateFormatter::MEDIUM,
167-
true
168-
);
169-
$data['created_at'] = (new \DateTime($data['created_at']))->format('Y-m-d H:i:s');
164+
165+
$data['created_at'] = $this->localeDate
166+
->scopeDate(null, $data['created_at'], true)
167+
->format('Y-m-d H:i:s');
168+
169+
$data['updated_at'] = $this->localeDate
170+
->scopeDate(null, $data['updated_at'], true)
171+
->format('Y-m-d H:i:s');
172+
170173
$exportData = $lines['data'][$data['email']];
171174
$exportData = $this->unsetDuplicateData($exportData);
172175

0 commit comments

Comments
 (0)