Skip to content

Commit 98aa2b5

Browse files
committed
ACP2E-2990: Customer "created_at" date Not Converted to store time zone upon export
- Fixed the static and integration test failure.
1 parent 0ac67b1 commit 98aa2b5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

app/code/Magento/CustomerImportExport/Plugin/Model/Export/FormatCustomerCreatedAt.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ public function __construct(
3636
}
3737

3838
/**
39+
* Format the created_at column based on the timezone configuration.
40+
*
3941
* @param Customer $subject
4042
* @param Item $item
41-
* @return Item
43+
* @return void
4244
*/
4345
public function beforeExportItem(
4446
Customer $subject,
4547
Item $item
46-
) {
48+
): void
49+
{
4750
$item->setData(
4851
self::COLUMN_CREATED_AT,
4952
$this->localeDate->formatDate(

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Customer\Model\Customer as CustomerModel;
1818
use Magento\Customer\Model\ResourceModel\Attribute\Collection;
1919
use Magento\Customer\Model\ResourceModel\Customer\Collection as CustomerCollection;
20+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
2021

2122
/**
2223
* Tests for customer export model.
@@ -50,6 +51,11 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
5051
*/
5152
private $attributeCollection;
5253

54+
/**
55+
* @var TimezoneInterface
56+
*/
57+
private $localeDate;
58+
5359
/**
5460
* @inheritdoc
5561
*/
@@ -58,6 +64,7 @@ protected function setUp(): void
5864
$this->objectManager = Bootstrap::getObjectManager();
5965
$this->_model = $this->objectManager->create(Customer::class);
6066
$this->attributeCollection = $this->objectManager->create(Collection::class);
67+
$this->localeDate = $this->objectManager->create(TimezoneInterface::class);
6168
}
6269

6370
/**
@@ -153,6 +160,11 @@ private function checkExportData(array $lines, array $expectedAttributes): void
153160
$customers = $this->objectManager->create(CustomerCollection::class);
154161
foreach ($customers as $customer) {
155162
$data = $this->processCustomerData($customer, $expectedAttributes);
163+
$data['created_at'] = $this->localeDate->formatDate(
164+
$data['created_at'],
165+
\IntlDateFormatter::MEDIUM,
166+
true
167+
);
156168
$exportData = $lines['data'][$data['email']];
157169
$exportData = $this->unsetDuplicateData($exportData);
158170

0 commit comments

Comments
 (0)