Skip to content

Commit fe60ed7

Browse files
committed
Merge branch 'MAGETWO-38563' of github.corp.ebay.com:magento-south/magento2ce into MAGETWO-38563
2 parents cbd1e2a + 3fd06fa commit fe60ed7

File tree

10 files changed

+86
-120
lines changed

10 files changed

+86
-120
lines changed

app/code/Magento/Customer/Model/Address.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Customer\Api\Data\AddressInterfaceFactory;
1010
use Magento\Customer\Api\Data\AddressInterface;
1111
use Magento\Customer\Api\Data\RegionInterfaceFactory;
12+
use Magento\Framework\Indexer\StateInterface;
1213

1314
/**
1415
* Customer address model
@@ -317,7 +318,10 @@ public function getEntityTypeId()
317318
*/
318319
public function afterSave()
319320
{
320-
$this->_getResource()->addCommitCallback([$this, 'reindex']);
321+
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
322+
if ($indexer->getState()->getStatus() !== StateInterface::STATUS_INVALID) {
323+
$this->_getResource()->addCommitCallback([$this, 'reindex']);
324+
}
321325
return parent::afterSave();
322326
}
323327

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\Exception\EmailNotConfirmedException;
1717
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
1818
use Magento\Framework\Exception\AuthenticationException;
19+
use Magento\Framework\Indexer\StateInterface;
1920

2021
/**
2122
* Customer model
@@ -210,22 +211,23 @@ class Customer extends \Magento\Framework\Model\AbstractModel
210211
* @param \Magento\Framework\Registry $registry
211212
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
212213
* @param \Magento\Eav\Model\Config $config
213-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
214+
* @param ScopeConfigInterface $scopeConfig
214215
* @param ResourceCustomer $resource
215216
* @param Share $configShare
216217
* @param AddressFactory $addressFactory
217218
* @param CollectionFactory $addressesFactory
218219
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
219220
* @param GroupRepositoryInterface $groupRepository
220-
* @param AttributeFactory $attributeFactory
221221
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
222222
* @param \Magento\Framework\Stdlib\DateTime $dateTime
223223
* @param CustomerInterfaceFactory $customerDataFactory
224224
* @param DataObjectProcessor $dataObjectProcessor
225225
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
226226
* @param CustomerMetadataInterface $metadataService
227-
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
227+
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
228+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
228229
* @param array $data
230+
*
229231
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
230232
*/
231233
public function __construct(
@@ -1085,7 +1087,10 @@ public function beforeDelete()
10851087
*/
10861088
public function afterSave()
10871089
{
1088-
$this->_getResource()->addCommitCallback([$this, 'reindex']);
1090+
$indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID);
1091+
if ($indexer->getState()->getStatus() !== StateInterface::STATUS_INVALID) {
1092+
$this->_getResource()->addCommitCallback([$this, 'reindex']);
1093+
}
10891094
return parent::afterSave();
10901095
}
10911096

app/code/Magento/Customer/Model/Resource/Customer/Grid/ServiceCollection.php

Lines changed: 0 additions & 104 deletions
This file was deleted.

app/code/Magento/Customer/Model/Visitor.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Customer\Model;
88

9+
use Magento\Framework\Indexer\StateInterface;
10+
911
/**
1012
* Class Visitor
1113
* @package Magento\Customer\Model
@@ -55,15 +57,21 @@ class Visitor extends \Magento\Framework\Model\AbstractModel
5557
*/
5658
protected $dateTime;
5759

60+
/**
61+
* @var \Magento\Framework\Indexer\IndexerRegistry
62+
*/
63+
protected $indexerRegistry;
64+
5865
/**
5966
* @param \Magento\Framework\Model\Context $context
6067
* @param \Magento\Framework\Registry $registry
6168
* @param \Magento\Framework\Session\SessionManagerInterface $session
6269
* @param \Magento\Framework\HTTP\Header $httpHeader
63-
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
64-
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
6570
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
6671
* @param \Magento\Framework\Stdlib\DateTime $dateTime
72+
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
73+
* @param \Magento\Framework\Model\Resource\AbstractResource|null $resource
74+
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
6775
* @param array $ignoredUserAgents
6876
* @param array $ignores
6977
* @param array $data
@@ -77,6 +85,7 @@ public function __construct(
7785
\Magento\Framework\HTTP\Header $httpHeader,
7886
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
7987
\Magento\Framework\Stdlib\DateTime $dateTime,
88+
\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
8089
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
8190
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
8291
array $ignoredUserAgents = [],
@@ -90,6 +99,7 @@ public function __construct(
9099
$this->ignores = $ignores;
91100
$this->scopeConfig = $scopeConfig;
92101
$this->dateTime = $dateTime;
102+
$this->indexerRegistry = $indexerRegistry;
93103
}
94104

95105
/**
@@ -149,6 +159,34 @@ public function initByRequest($observer)
149159
return $this;
150160
}
151161

162+
/**
163+
* Processing object after save data
164+
*
165+
* @return $this
166+
*/
167+
public function afterSave()
168+
{
169+
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
170+
if ($indexer->getState()->getStatus() !== StateInterface::STATUS_INVALID) {
171+
$this->_getResource()->addCommitCallback([$this, 'reindex']);
172+
}
173+
return parent::afterSave();
174+
}
175+
176+
/**
177+
* Init indexing process after visitor save
178+
*
179+
* @return void
180+
*/
181+
public function reindex()
182+
{
183+
if ($this->getCustomerId()) {
184+
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
185+
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
186+
$indexer->reindexRow($this->getCustomerId());
187+
}
188+
}
189+
152190
/**
153191
* Save visitor by request
154192
*

app/code/Magento/Customer/Ui/Component/FilterFactory.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function create($attribute, $context)
4444
'label' => __($attribute->getFrontendLabel()),
4545
];
4646
if ($attribute->getOptions()) {
47-
$config['options'] = $attribute->getOptions();
47+
$config['options'] = $this->getOptionsArray($attribute);
4848
$config['caption'] = __('Select...');
4949
}
5050
$arguments = [
@@ -57,6 +57,25 @@ public function create($attribute, $context)
5757
return $this->componentFactory->create($columnName, $this->getFilterType($attribute), $arguments);
5858
}
5959

60+
/**
61+
* @param \Magento\Customer\Api\Data\AttributeMetadataInterface $attribute
62+
* @return array
63+
*/
64+
protected function getOptionsArray($attribute)
65+
{
66+
$options = [];
67+
foreach ($attribute->getOptions() as $option) {
68+
array_push(
69+
$options,
70+
[
71+
'value' => $option->getValue(),
72+
'label' => $option->getLabel()
73+
]
74+
);
75+
}
76+
return $options;
77+
}
78+
6079
/**
6180
* @param \Magento\Customer\Api\Data\AttributeMetadataInterface $attribute
6281
* @return string

app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ class AttributeRepository
3434
protected $customerMetadata;
3535

3636
/**
37-
* @var \Magento\Customer\Api\AddressMetadataInterface
37+
* @var \Magento\Customer\Model\Metadata\AddressMetadata
3838
*/
3939
protected $addressMetadata;
4040

4141
/**
4242
* @param \Magento\Customer\Model\Resource\Attribute\Collection $attributeCollection
4343
* @param \Magento\Customer\Model\Resource\Address\Attribute\Collection $addressAttributeCollection
4444
* @param \Magento\Customer\Model\Metadata\CustomerMetadata $customerMetadata
45-
* @param AddressMetadataInterface $addressMetadata
45+
* @param \Magento\Customer\Model\Metadata\AddressMetadata $addressMetadata
4646
*/
4747
public function __construct(
4848
\Magento\Customer\Model\Resource\Attribute\Collection $attributeCollection,
4949
\Magento\Customer\Model\Resource\Address\Attribute\Collection $addressAttributeCollection,
5050
\Magento\Customer\Model\Metadata\CustomerMetadata $customerMetadata,
51-
\Magento\Customer\Api\AddressMetadataInterface $addressMetadata
51+
\Magento\Customer\Model\Metadata\AddressMetadata $addressMetadata
5252
) {
5353
$this->attributeCollection = $attributeCollection;
5454
$this->addressAttributeCollection = $addressAttributeCollection;

app/code/Magento/Customer/Ui/Component/Listing/Columns.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function addColumn(AttributeMetadataInterface $attribute)
9696
{
9797
$config['sortOrder'] = ++$this->columnSortOrder;
9898
$column = $this->columnFactory->create($attribute, $this->getContext(), $config);
99+
$column->prepare();
99100
$this->addComponent($attribute->getAttributeCode(), $column);
100101
}
101102

app/code/Magento/Indexer/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<preference for="Magento\Framework\Mview\View\StateInterface" type="Magento\Indexer\Model\Mview\View\State" />
1111
<preference for="Magento\Framework\Indexer\ConfigInterface" type="Magento\Indexer\Model\Config" />
1212
<preference for="Magento\Framework\Indexer\IndexerInterface" type="Magento\Indexer\Model\Indexer" />
13-
<preference for="Magento\Framework\Indexer\Table\StrategyInterface" type="Magento\Indexer\Model\Indexer\Table\Strategy" />
13+
<preference for="Magento\Framework\Indexer\Table\StrategyInterface" type="Magento\Framework\Indexer\Table\Strategy" />
1414
<type name="Magento\Framework\Indexer\Table\StrategyInterface" shared="false" />
1515
<type name="Magento\Indexer\Model\Indexer">
1616
<arguments>

app/code/Magento/Indexer/Test/Unit/Model/Indexer/Table/StrategyTest.php renamed to lib/internal/Magento/Framework/Indexer/Test/Unit/StrategyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Indexer\Test\Unit\Model\Indexer\Table;
6+
namespace Magento\Framework\Indexer\Test\Unit\Table;
77

88
/**
99
* Class StrategyTest

lib/internal/Magento/Framework/View/Element/UiComponentFactory.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function create($identifier, $name = null, array $arguments = [])
144144
$identifier,
145145
$bundleComponents[$identifier]
146146
);
147-
$componentArguments = array_merge($componentArguments, $arguments);
147+
$componentArguments = array_replace_recursive($componentArguments, $arguments);
148148
if (!isset($componentArguments['context'])) {
149149
$componentArguments['context'] = $this->contextFactory->create([
150150
'namespace' => $identifier
@@ -164,7 +164,10 @@ public function create($identifier, $name = null, array $arguments = [])
164164
$componentArguments['components'] = $components;
165165

166166
/** @var \Magento\Framework\View\Element\UiComponentInterface $component */
167-
$component = $this->objectManager->create($className, array_merge($componentArguments, $arguments));
167+
$component = $this->objectManager->create(
168+
$className,
169+
array_replace_recursive($componentArguments, $arguments)
170+
);
168171

169172
return $component;
170173
} else {
@@ -173,7 +176,7 @@ public function create($identifier, $name = null, array $arguments = [])
173176
/** @var \Magento\Framework\View\Element\UiComponentInterface $component */
174177
$component = $this->objectManager->create(
175178
$className,
176-
array_merge($componentArguments, $arguments)
179+
array_replace_recursive($componentArguments, $arguments)
177180
);
178181

179182
return $component;

0 commit comments

Comments
 (0)