/** * Copy variant group values to products * * @param array $variantGroups */ protected function copyValuesToProducts(array $variantGroups) { foreach ($variantGroups as $variantGroup) { $template = $variantGroup->getProductTemplate(); $products = $variantGroup->getProducts(); if ($template && count($template->getValuesData()) > 0 && count($products) > 0) { $skippedMessages = $this->productTplApplier->apply($template, $products->toArray()); $nbSkipped = count($skippedMessages); $nbUpdated = count($products) - $nbSkipped; $this->incrementUpdatedProductsCount($nbUpdated); if ($nbSkipped > 0) { $this->incrementSkippedProductsCount($skippedMessages, $nbSkipped); } } } }
/** * Copy the variant group values on any products belonging in the variant group * * @param GroupInterface $group */ protected function copyVariantGroupValues(GroupInterface $group) { $template = $group->getProductTemplate(); $products = $group->getProducts()->toArray(); $this->productTplApplier->apply($template, $products); }