Skip to content

Commit 4c306e0

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-2301' into SEP292023_PR_pradeep
2 parents 9fc3111 + 3ac303c commit 4c306e0

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

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

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
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_ADDRESS_PREFIX = '_address_';
24+
public const COLUMN_ADDRESS_PREFIX = '_address_';
2525

26-
const COLUMN_DEFAULT_BILLING = '_address_default_billing_';
26+
public const COLUMN_DEFAULT_BILLING = '_address_default_billing_';
2727

28-
const COLUMN_DEFAULT_SHIPPING = '_address_default_shipping_';
28+
public const COLUMN_DEFAULT_SHIPPING = '_address_default_shipping_';
2929

3030
/**#@-*/
3131

3232
/**#@+
3333
* Data row scopes
3434
*/
35-
const SCOPE_DEFAULT = 1;
35+
public const SCOPE_DEFAULT = 1;
3636

37-
const SCOPE_ADDRESS = -1;
37+
public const SCOPE_ADDRESS = -1;
3838

3939
/**#@-*/
4040

4141
/**#@+
4242
* Component entity names
4343
*/
44-
const COMPONENT_ENTITY_CUSTOMER = 'customer';
44+
public const COMPONENT_ENTITY_CUSTOMER = 'customer';
4545

46-
const COMPONENT_ENTITY_ADDRESS = 'address';
46+
public const COMPONENT_ENTITY_ADDRESS = 'address';
4747

4848
/**#@-*/
4949

5050
/**
5151
* Error code for orphan rows
5252
*/
53-
const ERROR_ROW_IS_ORPHAN = 'rowIsOrphan';
53+
public const ERROR_ROW_IS_ORPHAN = 'rowIsOrphan';
5454

5555
/**
5656
* @var \Magento\CustomerImportExport\Model\Import\Customer
@@ -85,14 +85,14 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
8585
];
8686

8787
/**
88-
* Customer attributes
88+
* Customer attribute
8989
*
9090
* @var string[]
9191
*/
9292
protected $_customerAttributes = [];
9393

9494
/**
95-
* Address attributes
95+
* Address attribute
9696
*
9797
* @var string[]
9898
*/
@@ -134,9 +134,9 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
134134
protected $needColumnCheck = true;
135135

136136
/**
137-
* Valid column names
137+
* Valid column name
138138
*
139-
* @array
139+
* @var string[]
140140
*/
141141
protected $validColumnNames = [
142142
Customer::COLUMN_DEFAULT_BILLING,
@@ -145,7 +145,7 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
145145
];
146146

147147
/**
148-
* {@inheritdoc}
148+
* @var string
149149
*/
150150
protected $masterAttributeCode = 'email';
151151

@@ -278,12 +278,19 @@ protected function _initAddressAttributes()
278278
*/
279279
protected function _importData()
280280
{
281+
if ($this->getIds()) {
282+
$this->_customerEntity->setIds($this->getIds());
283+
}
281284
$result = $this->_customerEntity->importData();
282285
$this->countItemsCreated += $this->_customerEntity->getCreatedItemsCount();
283286
$this->countItemsUpdated += $this->_customerEntity->getUpdatedItemsCount();
284287
$this->countItemsDeleted += $this->_customerEntity->getDeletedItemsCount();
285288
if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE) {
286-
$result = $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
289+
$addressEntityObject = $this->_addressEntity->setCustomerAttributes($this->_customerAttributes);
290+
if ($this->getIds() && $addressEntityObject !== null) {
291+
$addressEntityObject->setIds($this->getIds());
292+
}
293+
$result = $result && $addressEntityObject->importData();
287294
}
288295
if ($result) {
289296
$this->indexerProcessor->markIndexerAsInvalid();

app/code/Magento/CustomerImportExport/Model/ResourceModel/Import/CustomerComposite/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function _prepareRow(array $rowData)
8181
{
8282
$entityCustomer = CustomerComposite::COMPONENT_ENTITY_CUSTOMER;
8383
if ($this->_entityType == $entityCustomer) {
84-
if ($rowData['_scope'] == CustomerComposite::SCOPE_DEFAULT) {
84+
if ((isset($rowData['_scope'])) && $rowData['_scope'] == CustomerComposite::SCOPE_DEFAULT) {
8585
return $rowData;
8686
} else {
8787
return null;

app/code/Magento/CustomerImportExport/Test/Unit/Model/Import/CustomerCompositeTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,22 +255,26 @@ protected function _getModelMockForPrepareRowForDb()
255255
protected function _getModelMockForImportData($isDeleteBehavior, $customerImport, $addressImport)
256256
{
257257
$customerEntity = $this->_getCustomerEntityMock();
258+
$customerEntity->expects($this->once())->method('setIds')->willReturnSelf();
258259
$customerEntity->expects($this->once())->method('importData')->willReturn($customerImport);
259260

260261
$addressEntity = $this->_getAddressEntityMock();
261262
// address import starts only if customer import finished successfully
262263
if ($isDeleteBehavior || !$customerImport) {
263264
$addressEntity->expects($this->never())->method('importData');
264265
} else {
265-
$addressEntity->expects($this->once())->method('setCustomerAttributes')->willReturnSelf();
266+
$addressEntity->expects($this->atMost(2))->method('setCustomerAttributes')->willReturnSelf();
267+
$addressEntity->expects($this->once())->method('setIds')->willReturnSelf();
266268
$addressEntity->expects($this->once())->method('importData')->willReturn($addressImport);
267269
}
268270

269271
$data = $this->_getModelDependencies();
270272
$data['customer_entity'] = $customerEntity;
271273
$data['address_entity'] = $addressEntity;
272274

273-
return $this->_createModelMock($data);
275+
$obj = $this->_createModelMock($data);
276+
$obj->setIds([1, 2]);
277+
return $obj;
274278
}
275279

276280
/**

0 commit comments

Comments
 (0)