internalCreate example



                // If the variant was found over the number, update the existing                 if ($variant) {
                    $variant = $this->getVariantResource()->internalUpdate(
                        $variant->getId(),
                        $variantData,
                        $article
                    );
                } else {
                    // Otherwise, the number passed to use as order number for the new variant                     $variant = $this->getVariantResource()->internalCreate($variantData$article);
                }
            }

            if (!empty($variantData['isMain']) || !empty($variantData['standard'])) {
                $newMain = $variant;
                $newMain->setKind(1);
                $oldMainId = $article->getMainDetail()->getId();

                // Check for old main articles:                 // If old main article has configurator options, use it as a usual variant                 // if the old main article does not have any configurator options, delete it
if (empty($productId)) {
            throw new ParameterMissingException('Passed parameter array does not contain an articleId property');
        }

        $product = $this->getManager()->find(ProductModel::class$productId);

        if (!$product) {
            throw new NotFoundException(sprintf('Product by id %d not found', $productId));
        }

        $variant = $this->internalCreate($params$product);

        $violations = $this->getManager()->validate($variant);
        if ($violations->count() > 0) {
            throw new ValidationException($violations);
        }

        $this->getManager()->persist($variant);
        $this->flush();

        return $variant;
    }

    
Home | Imprint | This part of the site doesn't use cookies.