/**
  * @param Attribute $attribute
  * @param string $field
  * @return array
  */
 public function getPropertyValues(Attribute $attribute, $field)
 {
     $result = [];
     foreach ($attribute->getPropertiesByField($field) as $property) {
         $websiteId = $property->getWebsite() ? $property->getWebsite()->getId() : null;
         $fallback = $property->getFallback();
         if ($fallback) {
             $result[$websiteId] = new FallbackType($fallback);
         } else {
             $result[$websiteId] = $property->isValue();
         }
     }
     return $result;
 }
 public function testGetPropertiesByFieldAndGetPropertyByFieldAndWebsiteId()
 {
     $firstWebsite = $this->createWebsite(1);
     $secondWebsite = $this->createWebsite(2);
     $onViewDefault = new AttributeProperty();
     $onViewDefault->setField(AttributeProperty::FIELD_ON_PRODUCT_VIEW);
     $onViewFirst = new AttributeProperty();
     $onViewFirst->setField(AttributeProperty::FIELD_ON_PRODUCT_VIEW)->setWebsite($firstWebsite);
     $inFiltersDefault = new AttributeProperty();
     $inFiltersDefault->setField(AttributeProperty::FIELD_USE_IN_FILTERS);
     $inFiltersFirst = new AttributeProperty();
     $inFiltersFirst->setField(AttributeProperty::FIELD_USE_IN_FILTERS)->setWebsite($firstWebsite);
     $inFiltersSecond = new AttributeProperty();
     $inFiltersSecond->setField(AttributeProperty::FIELD_USE_IN_FILTERS)->setWebsite($secondWebsite);
     $attribute = new Attribute();
     $attribute->resetProperties([$onViewDefault, $onViewFirst, $inFiltersDefault, $inFiltersFirst, $inFiltersSecond]);
     $this->assertEquals([$onViewDefault, $onViewFirst], array_values($attribute->getPropertiesByField(AttributeProperty::FIELD_ON_PRODUCT_VIEW)->toArray()));
     $this->assertEquals([$inFiltersDefault, $inFiltersFirst, $inFiltersSecond], array_values($attribute->getPropertiesByField(AttributeProperty::FIELD_USE_IN_FILTERS)->toArray()));
     $this->assertEmpty($attribute->getPropertiesByField(AttributeProperty::FIELD_USE_IN_SORTING)->toArray());
     $this->assertEquals($onViewDefault, $attribute->getPropertyByFieldAndWebsiteId(AttributeProperty::FIELD_ON_PRODUCT_VIEW, null));
     $this->assertEquals($inFiltersSecond, $attribute->getPropertyByFieldAndWebsiteId(AttributeProperty::FIELD_USE_IN_FILTERS, $secondWebsite->getId()));
     $this->assertNull($attribute->getPropertyByFieldAndWebsiteId(AttributeProperty::FIELD_USE_IN_SORTING, $firstWebsite->getId()));
     $this->assertNull($attribute->getPropertyByFieldAndWebsiteId(AttributeProperty::FIELD_ON_PRODUCT_VIEW, 42));
 }