/** * @return array */ public function resolveAttributeColumns() { if (empty($this->attributesFields)) { // TODO: Put a Cursor to avoid a findAll on attributes (╯°□°)╯︵ ┻━┻ $attributes = $this->attributeRepository->findAll(); $currencyCodes = $this->currencyRepository->getActivatedCurrencyCodes(); $values = $this->valuesResolver->resolveEligibleValues($attributes); foreach ($values as $value) { $field = $this->resolveFlatAttributeName($value['attribute'], $value['locale'], $value['scope']); if (AttributeTypes::PRICE_COLLECTION === $value['type']) { $this->attributesFields[] = $field; foreach ($currencyCodes as $currencyCode) { $currencyField = sprintf('%s-%s', $field, $currencyCode); $this->attributesFields[] = $currencyField; } } elseif (AttributeTypes::METRIC === $value['type']) { $this->attributesFields[] = $field; $metricField = sprintf('%s-%s', $field, 'unit'); $this->attributesFields[] = $metricField; } else { $this->attributesFields[] = $field; } } } return $this->attributesFields; }
/** * {@inheritdoc} */ public function addAttributeToProduct(ProductInterface $product, AttributeInterface $attribute) { $requiredValues = $this->valuesResolver->resolveEligibleValues([$attribute]); foreach ($requiredValues as $value) { $this->addProductValue($product, $attribute, $value['locale'], $value['scope']); } }