/** * Returns a ProductValue * * @param ProductInterface $product * @param ColumnInfoInterface $columnInfo * * @return ProductValueInterface */ protected function getProductValue(ProductInterface $product, ColumnInfoInterface $columnInfo) { $productValue = $product->getValue($columnInfo->getName(), $columnInfo->getLocale(), $columnInfo->getScope()); if (null === $productValue) { $attribute = $columnInfo->getAttribute(); $locale = $columnInfo->getLocale(); $scope = $columnInfo->getScope(); $productValue = $this->productBuilder->createProductValue($attribute, $locale, $scope); $product->addValue($productValue); } return $productValue; }
/** * Add all the values required by the given attribute * * @param AttributeInterface $attribute * @param LocaleInterface $locale */ protected function addValues(AttributeInterface $attribute, $locale) { if ($attribute->isScopable()) { foreach ($locale->getChannels() as $channel) { $key = $attribute->getCode() . '_' . $channel->getCode(); $value = $this->productBuilder->createProductValue($attribute, $locale->getCode(), $channel->getCode()); $this->productBuilder->addMissingPrices($value); $this->values[$key] = $value; } } else { $value = $this->productBuilder->createProductValue($attribute, $locale->getCode()); $this->productBuilder->addMissingPrices($value); $this->values[$attribute->getCode()] = $value; } }