/** * {@inheritdoc} */ public function update(ProductTemplateInterface $template, array $products) { $updates = $template->getValuesData(); foreach ($updates as $attributeCode => $values) { foreach ($values as $value) { $this->productUpdater->setValue($products, $attributeCode, $value['value'], $value['locale'], $value['scope']); } } }
/** * Set product values with the one stored inside $this->values * * @param ProductInterface $product */ protected function setProductValues(ProductInterface $product) { foreach ($this->values as $value) { $rawData = $this->normalizer->normalize($value->getData(), 'json', ['entity' => 'product']); // if the value is localizable, let's use the locale the user has chosen in the form $locale = null !== $value->getLocale() ? $this->getLocale()->getCode() : null; $this->productUpdater->setValue([$product], $value->getAttribute()->getCode(), $rawData, $locale, $value->getScope()); } }