Skip to content

Commit 258318e

Browse files
committed
Merge remote-tracking branch 'adobe-commerce-tier-4/ACP2E-2990' into Tier4-Kings-PR-05-17-2024
2 parents 2e710e1 + 8afce66 commit 258318e

File tree

2 files changed

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

2 files changed

+40
-7
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,25 @@ class Customer extends \Magento\ImportExport\Model\Export\Entity\AbstractEav
2121
* Names that begins with underscore is not an attribute. This name convention is for
2222
* to avoid interference with same attribute name.
2323
*/
24-
const COLUMN_EMAIL = 'email';
24+
public const COLUMN_EMAIL = 'email';
2525

26-
const COLUMN_WEBSITE = '_website';
26+
public const COLUMN_WEBSITE = '_website';
2727

28-
const COLUMN_STORE = '_store';
28+
public const COLUMN_STORE = '_store';
29+
30+
private const COLUMN_CREATED_AT = 'created_at';
31+
32+
private const COLUMN_UPDATED_AT = 'updated_at';
2933

3034
/**
31-
* Attribute collection name
35+
* A constant declaration for attribute collection name
3236
*/
33-
const ATTRIBUTE_COLLECTION_NAME = \Magento\Customer\Model\ResourceModel\Attribute\Collection::class;
37+
public const ATTRIBUTE_COLLECTION_NAME = \Magento\Customer\Model\ResourceModel\Attribute\Collection::class;
3438

3539
/**
3640
* XML path to page size parameter
3741
*/
38-
const XML_PATH_PAGE_SIZE = 'export/customer_page_size/customer';
42+
public const XML_PATH_PAGE_SIZE = 'export/customer_page_size/customer';
3943

4044
/**
4145
* @var array
@@ -139,7 +143,7 @@ protected function _getEntityCollection()
139143
}
140144

141145
/**
142-
* {@inheritdoc}
146+
* @inheritdoc
143147
*/
144148
protected function _getHeaderColumns()
145149
{
@@ -159,6 +163,18 @@ public function exportItem($item)
159163
$row[self::COLUMN_WEBSITE] = $this->_websiteIdToCode[$item->getWebsiteId()];
160164
$row[self::COLUMN_STORE] = $this->_storeIdToCode[$item->getStoreId()];
161165

166+
if (isset($row[self::COLUMN_CREATED_AT])) {
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');
176+
}
177+
162178
$this->getWriter()->writeRow($row);
163179
}
164180

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
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.
2324
*
2425
* @magentoAppArea adminhtml
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2527
*/
2628
class CustomerTest extends \PHPUnit\Framework\TestCase
2729
{
@@ -50,6 +52,11 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
5052
*/
5153
private $attributeCollection;
5254

55+
/**
56+
* @var TimezoneInterface
57+
*/
58+
private $localeDate;
59+
5360
/**
5461
* @inheritdoc
5562
*/
@@ -58,6 +65,7 @@ protected function setUp(): void
5865
$this->objectManager = Bootstrap::getObjectManager();
5966
$this->_model = $this->objectManager->create(Customer::class);
6067
$this->attributeCollection = $this->objectManager->create(Collection::class);
68+
$this->localeDate = $this->objectManager->create(TimezoneInterface::class);
6169
}
6270

6371
/**
@@ -153,6 +161,15 @@ private function checkExportData(array $lines, array $expectedAttributes): void
153161
$customers = $this->objectManager->create(CustomerCollection::class);
154162
foreach ($customers as $customer) {
155163
$data = $this->processCustomerData($customer, $expectedAttributes);
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+
156173
$exportData = $lines['data'][$data['email']];
157174
$exportData = $this->unsetDuplicateData($exportData);
158175

0 commit comments

Comments
 (0)