public function testGetsAttributeValuesForEntity() { $entityId = 400; $attribute1 = new TestCustomAttribute(1, 'a1'); $attribute2 = new TestCustomAttribute(2, 'a2'); $attribute3 = new TestCustomAttribute(3, 'a3'); $value1 = new AttributeEntityValue(1, $entityId, 'att1'); $value3 = new AttributeEntityValue(3, $entityId, 'att3'); $value4 = new AttributeEntityValue(4, $entityId, 'att2'); $list = new AttributeList(); $list->AddDefinition($attribute1); $list->AddDefinition($attribute2); $list->AddDefinition($attribute3); $list->AddValue($value1); $list->AddValue($value3); $list->AddValue($value4); $values = $list->GetAttributes($entityId); $this->assertEquals(array(new Attribute($attribute1, 'att1'), new Attribute($attribute2, null), new Attribute($attribute3, 'att3')), $values); }
public function GetAttributes($category, $entityIds = array()) { if (!is_array($entityIds) && !empty($entityIds)) { $entityIds = array($entityIds); } $attributeList = new AttributeList(); $attributes = $this->attributeRepository->GetByCategory($category); $stopwatch = new StopWatch(); $stopwatch->Start(); $values = $this->attributeRepository->GetEntityValues($category, $entityIds); foreach ($attributes as $attribute) { $attributeList->AddDefinition($attribute); } foreach ($values as $value) { $attributeList->AddValue($value); } $stopwatch->Stop(); Log::Debug('Took %d seconds to load custom attributes for category %s', $stopwatch->GetTotalSeconds(), $category); return $attributeList; }