/**
  * @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);
 }
Ejemplo n.º 2
0
 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));
 }
 public function testGetList()
 {
     $attributeCode = 'attribute_code';
     $billingPrefix = 'billing_';
     $this->customerMetadata->expects($this->once())->method('getAllAttributesMetadata')->willReturn([]);
     $this->addressMetadata->expects($this->once())->method('getAllAttributesMetadata')->willReturn([$this->attribute]);
     $this->addressMetadataManagement->expects($this->once())->method('canBeFilterableInGrid')->with($this->attribute)->willReturn(true);
     $this->addressMetadataManagement->expects($this->once())->method('canBeSearchableInGrid')->with($this->attribute)->willReturn(true);
     $this->attribute->expects($this->atLeastOnce())->method('getAttributeCode')->willReturn($attributeCode);
     $this->attribute->expects($this->once())->method('getFrontendInput')->willReturn('frontend-input');
     $this->attribute->expects($this->once())->method('getFrontendLabel')->willReturn('frontend-label');
     $this->attribute->expects($this->once())->method('getBackendType')->willReturn('backend-type');
     $this->attribute->expects($this->once())->method('getOptions')->willReturn([$this->option]);
     $this->attribute->expects($this->once())->method('getIsUsedInGrid')->willReturn(true);
     $this->attribute->expects($this->once())->method('getIsVisibleInGrid')->willReturn(true);
     $this->attribute->expects($this->once())->method('getValidationRules')->willReturn([]);
     $this->attribute->expects($this->once())->method('isRequired')->willReturn(false);
     $this->option->expects($this->once())->method('getLabel')->willReturn('Label');
     $this->option->expects($this->once())->method('getValue')->willReturn('Value');
     $this->attributeFilter->expects($this->once())->method('filter')->willReturnArgument(0);
     $this->assertEquals([$billingPrefix . $attributeCode => ['attribute_code' => 'billing_attribute_code', 'frontend_input' => 'frontend-input', 'frontend_label' => 'frontend-label', 'backend_type' => 'backend-type', 'options' => [['label' => 'Label', 'value' => 'Value']], 'is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true, 'validation_rules' => [], 'required' => false, 'entity_type_code' => 'customer_address']], $this->component->getList());
 }