/** * @param Attribute $attribute */ protected function addTestProperties(Attribute $attribute) { $attribute->addProperty($this->createProperty(null, AttributeProperty::FIELD_ON_PRODUCT_VIEW, false))->addProperty($this->createProperty(1, AttributeProperty::FIELD_ON_PRODUCT_VIEW, true))->addProperty($this->createProperty(2, AttributeProperty::FIELD_ON_PRODUCT_VIEW, null, FallbackType::SYSTEM))->addProperty($this->createProperty(null, AttributeProperty::FIELD_IN_PRODUCT_LISTING, true))->addProperty($this->createProperty(1, AttributeProperty::FIELD_IN_PRODUCT_LISTING, false))->addProperty($this->createProperty(2, AttributeProperty::FIELD_IN_PRODUCT_LISTING, null, FallbackType::SYSTEM))->addProperty($this->createProperty(null, AttributeProperty::FIELD_USE_IN_SORTING, false))->addProperty($this->createProperty(1, AttributeProperty::FIELD_USE_IN_SORTING, true))->addProperty($this->createProperty(2, AttributeProperty::FIELD_USE_IN_SORTING, null, FallbackType::SYSTEM))->addProperty($this->createProperty(null, AttributeProperty::FIELD_ON_ADVANCED_SEARCH, true))->addProperty($this->createProperty(1, AttributeProperty::FIELD_ON_ADVANCED_SEARCH, false))->addProperty($this->createProperty(2, AttributeProperty::FIELD_ON_ADVANCED_SEARCH, null, FallbackType::SYSTEM))->addProperty($this->createProperty(null, AttributeProperty::FIELD_ON_PRODUCT_COMPARISON, true))->addProperty($this->createProperty(1, AttributeProperty::FIELD_ON_PRODUCT_COMPARISON, false))->addProperty($this->createProperty(2, AttributeProperty::FIELD_ON_PRODUCT_COMPARISON, null, FallbackType::SYSTEM))->addProperty($this->createProperty(null, AttributeProperty::FIELD_USE_IN_FILTERS, false))->addProperty($this->createProperty(1, AttributeProperty::FIELD_USE_IN_FILTERS, true))->addProperty($this->createProperty(2, AttributeProperty::FIELD_USE_IN_FILTERS, null, FallbackType::SYSTEM)); }
/** * @param Attribute $attribute * @param string $field * @param array $values */ public function setPropertyValues(Attribute $attribute, $field, array $values) { foreach ($values as $websiteId => $value) { $attributeProperty = $attribute->getPropertyByFieldAndWebsiteId($field, $websiteId); if (!$attributeProperty) { $attributeProperty = new AttributeProperty(); $attributeProperty->setField($field); if ($websiteId) { $attributeProperty->setWebsite($this->databaseHelper->findWebsite($websiteId)); } $attribute->addProperty($attributeProperty); } if ($value instanceof FallbackType) { $attributeProperty->setValue(null)->setFallback($value->getType()); } else { $attributeProperty->setValue($value)->setFallback(null); } } }