/** * @return array */ public function getList() { if (!$this->attributes) { $this->attributes = $this->getListForEntity($this->customerMetadata->getAllAttributesMetadata(), CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, $this->customerMetadataManagement); $this->attributes = array_merge($this->attributes, $this->getListForEntity($this->addressMetadata->getAllAttributesMetadata(), AddressMetadataInterface::ENTITY_TYPE_ADDRESS, $this->addressMetadataManagement)); } return $this->attributeFilter->filter($this->attributes); }
public function testFilter() { $attributeCode = 'attribute-code'; $attributeCodeTwo = 'attribute-code2'; $tableName = 'customer_grid_flat'; $attributes = [$attributeCode => [AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCode, AttributeMetadataInterface::FRONTEND_INPUT => 'input', AttributeMetadataInterface::FRONTEND_LABEL => 'Frontend label', AttributeMetadataInterface::BACKEND_TYPE => 'static', AttributeMetadataInterface::OPTIONS => [], AttributeMetadataInterface::IS_USED_IN_GRID => true, AttributeMetadataInterface::IS_VISIBLE_IN_GRID => true, AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => true, AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => true], $attributeCodeTwo => [AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCodeTwo, AttributeMetadataInterface::FRONTEND_INPUT => 'input', AttributeMetadataInterface::FRONTEND_LABEL => 'Frontend label two', AttributeMetadataInterface::BACKEND_TYPE => 'static', AttributeMetadataInterface::OPTIONS => [], AttributeMetadataInterface::IS_USED_IN_GRID => false, AttributeMetadataInterface::IS_VISIBLE_IN_GRID => false, AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => false, AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => false]]; $this->indexerRegistry->expects($this->once())->method('get')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID)->willReturn($this->indexer); $this->indexer->expects($this->once())->method('getState')->willReturn($this->indexerState); $this->indexerState->expects($this->once())->method('getStatus')->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->flatScopeResolver->expects($this->once())->method('resolve')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID, [])->willReturn($tableName); $this->resource->expects($this->once())->method('getConnection')->willReturn($this->connection); $this->connection->expects($this->once())->method('describeTable')->with($tableName)->willReturn(['attribute-code' => ['Attribute data']]); $this->assertArrayNotHasKey($attributeCodeTwo, $this->model->filter($attributes)); }