setArticleDetail example


    private $shippingTime;

    public function __construct()
    {
        $this->prices = new ArrayCollection();
        $this->images = new ArrayCollection();
        $this->configuratorOptions = new ArrayCollection();
        $this->notifications = new ArrayCollection();
        $this->attribute = new ProductAttribute();
        $this->attribute->setArticleDetail($this);
    }

    /** * @return int */
    public function getId()
    {
        return $this->id;
    }

    /** * @param string $number * * @return Detail */

            // Fills the model by using the array $params             $premiumModel->fromArray($params);

            // find the shop-model by using the subShopId             /** @var Shop $shop */
            $shop = $this->get('models')->find(Shop::class$params['shopId']);
            $premiumModel->setShop($shop);

            /** @var Detail $productVariant */
            $productVariant = $this->getArticleDetailRepository()->findOneBy(['number' => $params['orderNumber']]);
            $premiumModel->setArticleDetail($productVariant);

            // If the product is already set as a premium-product             $repository = $this->get('models')->getRepository(Premium::class);
            $result = $repository->findByOrderNumber($params['orderNumber']);
            $result = $this->get('models')->toArray($result);

            if (!empty($result) && $params['shopId'] == $result[0]['shopId']) {
                $this->View()->assign(['success' => false, 'errorMsg' => 'The product already is a premium-product.']);

                return;
            }

            
$variant = $this->get('models')->getRepository(ProductVariant::class)->find($variantId);
        if (!$variant) {
            $this->View()->assign([
                'success' => false,
                'message' => sprintf('Product variant by id %s not found', $variantId),
            ]);

            return;
        }

        $esd = new Esd();
        $esd->setArticleDetail($variant);

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

        $this->View()->assign([
            'success' => true,
        ]);
    }

    /** * Event listener function of the product backend module. * Will be fired when the user saves ESD */


    /** * Helper function which creates a variant image for the passed product image. * * @return Image */
    public function createVariantImage(Image $articleImage, Detail $variant)
    {
        $variantImage = new Image();
        $variantImage->setParent($articleImage);
        $variantImage->setArticleDetail($variant);
        $variantImage->setPosition($articleImage->getPosition());
        $variantImage->setMain($articleImage->getMain());
        $variantImage->setExtension($articleImage->getExtension());

        return $variantImage;
    }

    /** * @param Collection|array $options * * @return Mapping */
Home | Imprint | This part of the site doesn't use cookies.