コード例 #1
0
 /**
  * Relate simple products to configurable
  *
  * @param ProductInterface $product
  * @param ProductExtensionInterface $extensionAttributes
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 private function setLinkedProducts(ProductInterface $product, ProductExtensionInterface $extensionAttributes)
 {
     $associatedProductIds = $product->hasData('associated_product_ids') ? $product->getData('associated_product_ids') : [];
     $variationsMatrix = $this->getVariationMatrixFromProduct($product);
     if ($associatedProductIds || $variationsMatrix) {
         $this->variationHandler->prepareAttributeSet($product);
     }
     if (!empty($variationsMatrix)) {
         $generatedProductIds = $this->variationHandler->generateSimpleProducts($product, $variationsMatrix);
         $associatedProductIds = array_merge($associatedProductIds, $generatedProductIds);
     }
     $extensionAttributes->setConfigurableProductLinks(array_filter($associatedProductIds));
 }
コード例 #2
0
 /**
  * Relate simple products to configurable
  *
  * @param ProductInterface $product
  * @param ProductExtensionInterface $extensionAttributes
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 private function setLinkedProducts(ProductInterface $product, ProductExtensionInterface $extensionAttributes)
 {
     $associatedProductIds = $this->request->getPost('associated_product_ids', []);
     $variationsMatrix = $this->request->getParam('variations-matrix', []);
     if (!empty($variationsMatrix)) {
         $generatedProductIds = $this->variationHandler->generateSimpleProducts($product, $variationsMatrix);
         $associatedProductIds = array_merge($associatedProductIds, $generatedProductIds);
     }
     $extensionAttributes->setConfigurableProductLinks(array_filter($associatedProductIds));
 }