Skip to content

Commit

Permalink
Merge branch 'MAGETWO-38563' of github.corp.ebay.com:magento-south/ma…
Browse files Browse the repository at this point in the history
…gento2ce into MAGETWO-38563
  • Loading branch information
slavvka committed Aug 5, 2015
2 parents cbd1e2a + 3fd06fa commit fe60ed7
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 120 deletions.
6 changes: 5 additions & 1 deletion app/code/Magento/Customer/Model/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Customer\Api\Data\AddressInterfaceFactory;
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Api\Data\RegionInterfaceFactory;
use Magento\Framework\Indexer\StateInterface;

/**
* Customer address model
Expand Down Expand Up @@ -317,7 +318,10 @@ public function getEntityTypeId()
*/
public function afterSave()
{
$this->_getResource()->addCommitCallback([$this, 'reindex']);
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
if ($indexer->getState()->getStatus() !== StateInterface::STATUS_INVALID) {
$this->_getResource()->addCommitCallback([$this, 'reindex']);
}
return parent::afterSave();
}

Expand Down
13 changes: 9 additions & 4 deletions app/code/Magento/Customer/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Magento\Framework\Exception\EmailNotConfirmedException;
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Indexer\StateInterface;

/**
* Customer model
Expand Down Expand Up @@ -210,22 +211,23 @@ class Customer extends \Magento\Framework\Model\AbstractModel
* @param \Magento\Framework\Registry $registry
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Config $config
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param ScopeConfigInterface $scopeConfig
* @param ResourceCustomer $resource
* @param Share $configShare
* @param AddressFactory $addressFactory
* @param CollectionFactory $addressesFactory
* @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
* @param GroupRepositoryInterface $groupRepository
* @param AttributeFactory $attributeFactory
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param CustomerInterfaceFactory $customerDataFactory
* @param DataObjectProcessor $dataObjectProcessor
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
* @param CustomerMetadataInterface $metadataService
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand Down Expand Up @@ -1085,7 +1087,10 @@ public function beforeDelete()
*/
public function afterSave()
{
$this->_getResource()->addCommitCallback([$this, 'reindex']);
$indexer = $this->indexerRegistry->get(self::CUSTOMER_GRID_INDEXER_ID);
if ($indexer->getState()->getStatus() !== StateInterface::STATUS_INVALID) {
$this->_getResource()->addCommitCallback([$this, 'reindex']);
}
return parent::afterSave();
}

Expand Down

This file was deleted.

42 changes: 40 additions & 2 deletions app/code/Magento/Customer/Model/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Magento\Customer\Model;

use Magento\Framework\Indexer\StateInterface;

/**
* Class Visitor
* @package Magento\Customer\Model
Expand Down Expand Up @@ -55,15 +57,21 @@ class Visitor extends \Magento\Framework\Model\AbstractModel
*/
protected $dateTime;

/**
* @var \Magento\Framework\Indexer\IndexerRegistry
*/
protected $indexerRegistry;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Session\SessionManagerInterface $session
* @param \Magento\Framework\HTTP\Header $httpHeader
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry
* @param \Magento\Framework\Model\Resource\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $ignoredUserAgents
* @param array $ignores
* @param array $data
Expand All @@ -77,6 +85,7 @@ public function __construct(
\Magento\Framework\HTTP\Header $httpHeader,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\Stdlib\DateTime $dateTime,
\Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $ignoredUserAgents = [],
Expand All @@ -90,6 +99,7 @@ public function __construct(
$this->ignores = $ignores;
$this->scopeConfig = $scopeConfig;
$this->dateTime = $dateTime;
$this->indexerRegistry = $indexerRegistry;
}

/**
Expand Down Expand Up @@ -149,6 +159,34 @@ public function initByRequest($observer)
return $this;
}

/**
* Processing object after save data
*
* @return $this
*/
public function afterSave()
{
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
if ($indexer->getState()->getStatus() !== StateInterface::STATUS_INVALID) {
$this->_getResource()->addCommitCallback([$this, 'reindex']);
}
return parent::afterSave();
}

/**
* Init indexing process after visitor save
*
* @return void
*/
public function reindex()
{
if ($this->getCustomerId()) {
/** @var \Magento\Framework\Indexer\IndexerInterface $indexer */
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
$indexer->reindexRow($this->getCustomerId());
}
}

/**
* Save visitor by request
*
Expand Down
21 changes: 20 additions & 1 deletion app/code/Magento/Customer/Ui/Component/FilterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function create($attribute, $context)
'label' => __($attribute->getFrontendLabel()),
];
if ($attribute->getOptions()) {
$config['options'] = $attribute->getOptions();
$config['options'] = $this->getOptionsArray($attribute);
$config['caption'] = __('Select...');
}
$arguments = [
Expand All @@ -57,6 +57,25 @@ public function create($attribute, $context)
return $this->componentFactory->create($columnName, $this->getFilterType($attribute), $arguments);
}

/**
* @param \Magento\Customer\Api\Data\AttributeMetadataInterface $attribute
* @return array
*/
protected function getOptionsArray($attribute)
{
$options = [];
foreach ($attribute->getOptions() as $option) {
array_push(
$options,
[
'value' => $option->getValue(),
'label' => $option->getLabel()
]
);
}
return $options;
}

/**
* @param \Magento\Customer\Api\Data\AttributeMetadataInterface $attribute
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ class AttributeRepository
protected $customerMetadata;

/**
* @var \Magento\Customer\Api\AddressMetadataInterface
* @var \Magento\Customer\Model\Metadata\AddressMetadata
*/
protected $addressMetadata;

/**
* @param \Magento\Customer\Model\Resource\Attribute\Collection $attributeCollection
* @param \Magento\Customer\Model\Resource\Address\Attribute\Collection $addressAttributeCollection
* @param \Magento\Customer\Model\Metadata\CustomerMetadata $customerMetadata
* @param AddressMetadataInterface $addressMetadata
* @param \Magento\Customer\Model\Metadata\AddressMetadata $addressMetadata
*/
public function __construct(
\Magento\Customer\Model\Resource\Attribute\Collection $attributeCollection,
\Magento\Customer\Model\Resource\Address\Attribute\Collection $addressAttributeCollection,
\Magento\Customer\Model\Metadata\CustomerMetadata $customerMetadata,
\Magento\Customer\Api\AddressMetadataInterface $addressMetadata
\Magento\Customer\Model\Metadata\AddressMetadata $addressMetadata
) {
$this->attributeCollection = $attributeCollection;
$this->addressAttributeCollection = $addressAttributeCollection;
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Customer/Ui/Component/Listing/Columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function addColumn(AttributeMetadataInterface $attribute)
{
$config['sortOrder'] = ++$this->columnSortOrder;
$column = $this->columnFactory->create($attribute, $this->getContext(), $config);
$column->prepare();
$this->addComponent($attribute->getAttributeCode(), $column);
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Indexer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<preference for="Magento\Framework\Mview\View\StateInterface" type="Magento\Indexer\Model\Mview\View\State" />
<preference for="Magento\Framework\Indexer\ConfigInterface" type="Magento\Indexer\Model\Config" />
<preference for="Magento\Framework\Indexer\IndexerInterface" type="Magento\Indexer\Model\Indexer" />
<preference for="Magento\Framework\Indexer\Table\StrategyInterface" type="Magento\Indexer\Model\Indexer\Table\Strategy" />
<preference for="Magento\Framework\Indexer\Table\StrategyInterface" type="Magento\Framework\Indexer\Table\Strategy" />
<type name="Magento\Framework\Indexer\Table\StrategyInterface" shared="false" />
<type name="Magento\Indexer\Model\Indexer">
<arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Indexer\Test\Unit\Model\Indexer\Table;
namespace Magento\Framework\Indexer\Test\Unit\Table;

/**
* Class StrategyTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function create($identifier, $name = null, array $arguments = [])
$identifier,
$bundleComponents[$identifier]
);
$componentArguments = array_merge($componentArguments, $arguments);
$componentArguments = array_replace_recursive($componentArguments, $arguments);
if (!isset($componentArguments['context'])) {
$componentArguments['context'] = $this->contextFactory->create([
'namespace' => $identifier
Expand All @@ -164,7 +164,10 @@ public function create($identifier, $name = null, array $arguments = [])
$componentArguments['components'] = $components;

/** @var \Magento\Framework\View\Element\UiComponentInterface $component */
$component = $this->objectManager->create($className, array_merge($componentArguments, $arguments));
$component = $this->objectManager->create(
$className,
array_replace_recursive($componentArguments, $arguments)
);

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

return $component;
Expand Down

0 comments on commit fe60ed7

Please sign in to comment.