/** * Constructor * * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param EavValidationRules $eavValidationRules * @param CustomerCollectionFactory $customerCollectionFactory * @param Config $eavConfig * @param FilterPool $filterPool * @param array $meta * @param array $data */ public function __construct($name, $primaryFieldName, $requestFieldName, EavValidationRules $eavValidationRules, CustomerCollectionFactory $customerCollectionFactory, Config $eavConfig, FilterPool $filterPool, array $meta = [], array $data = []) { parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); $this->eavValidationRules = $eavValidationRules; $this->collection = $customerCollectionFactory->create(); $this->collection->addAttributeToSelect('*'); $this->eavConfig = $eavConfig; $this->filterPool = $filterPool; $this->meta['customer']['fields'] = $this->getAttributesMeta($this->eavConfig->getEntityType('customer')); $this->meta['address']['fields'] = $this->getAttributesMeta($this->eavConfig->getEntityType('customer_address')); }
/** * Initialize existent customers data * * @return $this */ protected function _initCustomers() { if (empty($this->_customers)) { // add customer default addresses column name to customer attribute mapping array $this->_customerCollection->addAttributeToSelect(self::$_defaultAddressAttributeMapping); // filter customer collection $this->_customerCollection = $this->_customerEntity->filterEntityCollection($this->_customerCollection); $customers = []; $addCustomer = function (\Magento\Customer\Model\Customer $customer) use(&$customers) { $customers[$customer->getId()] = $customer->getData(); }; $this->_byPagesIterator->iterate($this->_customerCollection, $this->_pageSize, [$addCustomer]); $this->_customers = $customers; } return $this; }
/** * Add field to select * * @param string|array $field * @param string|null $alias * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function addField($field, $alias = null) { $this->collection->addAttributeToSelect($field); }