Skip to content

Commit d2a4bc8

Browse files
author
Roman Lytvynenko
committed
Merge branch 'MC-31470' of https://github.com/magento-tango/magento2ce into Tango-PR-02-25-2020-23
2 parents abe7f81 + 6431f32 commit d2a4bc8

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Model\Indexer;
7+
8+
use Magento\Customer\Model\Customer;
9+
10+
/**
11+
* Customer indexer
12+
*/
13+
class Processor extends \Magento\Framework\Indexer\AbstractProcessor
14+
{
15+
const INDEXER_ID = Customer::CUSTOMER_GRID_INDEXER_ID;
16+
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\CustomerImportExport\Model\Import;
77

88
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
9+
use Magento\Customer\Model\Indexer\Processor;
910

1011
/**
1112
* Import entity customer combined model
@@ -148,6 +149,11 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
148149
*/
149150
protected $masterAttributeCode = 'email';
150151

152+
/**
153+
* @var Processor
154+
*/
155+
private $indexerProcessor;
156+
151157
/**
152158
* @param \Magento\Framework\Stdlib\StringUtils $string
153159
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -158,6 +164,7 @@ class CustomerComposite extends \Magento\ImportExport\Model\Import\AbstractEntit
158164
* @param \Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory $dataFactory
159165
* @param \Magento\CustomerImportExport\Model\Import\CustomerFactory $customerFactory
160166
* @param \Magento\CustomerImportExport\Model\Import\AddressFactory $addressFactory
167+
* @param Processor $indexerProcessor
161168
* @param array $data
162169
* @throws \Magento\Framework\Exception\LocalizedException
163170
*
@@ -173,6 +180,7 @@ public function __construct(
173180
\Magento\CustomerImportExport\Model\ResourceModel\Import\CustomerComposite\DataFactory $dataFactory,
174181
\Magento\CustomerImportExport\Model\Import\CustomerFactory $customerFactory,
175182
\Magento\CustomerImportExport\Model\Import\AddressFactory $addressFactory,
183+
Processor $indexerProcessor,
176184
array $data = []
177185
) {
178186
parent::__construct($string, $scopeConfig, $importFactory, $resourceHelper, $resource, $errorAggregator, $data);
@@ -230,6 +238,7 @@ public function __construct(
230238
} else {
231239
$this->_nextCustomerId = $resourceHelper->getNextAutoincrement($this->_customerEntity->getEntityTable());
232240
}
241+
$this->indexerProcessor = $indexerProcessor;
233242
}
234243

235244
/**
@@ -273,11 +282,12 @@ protected function _importData()
273282
$this->countItemsCreated += $this->_customerEntity->getCreatedItemsCount();
274283
$this->countItemsUpdated += $this->_customerEntity->getUpdatedItemsCount();
275284
$this->countItemsDeleted += $this->_customerEntity->getDeletedItemsCount();
276-
277285
if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE) {
278-
return $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
286+
$result = $result && $this->_addressEntity->setCustomerAttributes($this->_customerAttributes)->importData();
287+
}
288+
if ($result) {
289+
$this->indexerProcessor->markIndexerAsInvalid();
279290
}
280-
281291
return $result;
282292
}
283293

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\ImportExport\Model\Import\Source\Csv;
1616

1717
/**
18-
* Customer composite test
18+
* The test for Customer composite model
1919
*
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2121
*/
@@ -88,6 +88,12 @@ class CustomerCompositeTest extends \PHPUnit\Framework\TestCase
8888
*/
8989
protected $errorFactory;
9090

91+
/**
92+
* @var \Magento\Customer\Model\Indexer\Processor
93+
* |\PHPUnit\Framework\MockObject\MockObject
94+
*/
95+
private $indexerProcessor;
96+
9197
/**
9298
* Expected prepared data after method CustomerComposite::_prepareRowForDb
9399
*
@@ -141,6 +147,7 @@ protected function setUp()
141147
->getMock();
142148

143149
$this->_scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
150+
$this->indexerProcessor = $this->createMock(\Magento\Customer\Model\Indexer\Processor::class);
144151
}
145152

146153
/**
@@ -159,6 +166,7 @@ protected function _createModelMock($data)
159166
$this->_dataFactory,
160167
$this->_customerFactory,
161168
$this->_addressFactory,
169+
$this->indexerProcessor,
162170
$data
163171
);
164172
}

0 commit comments

Comments
 (0)