getArticleDetailRepository example

throw new Exception('No ordernumber was entered.');
            }
            // 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;
            }
/** * Event listener function of the product backend module. Fired when the user * edit or create an product variant and clicks the save button which displayed on bottom of the product * variant detail window. */
    public function saveDetailAction()
    {
        $data = $this->Request()->getParams();
        $id = (int) $this->Request()->getParam('id');

        if ($id > 0) {
            $detail = $this->getArticleDetailRepository()->find($id);
            if (!$detail instanceof ProductVariant) {
                throw new ModelNotFoundException(ProductVariant::class$id);
            }
        } else {
            $detail = new ProductVariant();
        }
        $detail = $this->saveDetail($data$detail);
        $data['id'] = $detail->getId();
        $this->View()->assign([
            'success' => true,
            'data' => $data,
        ]);
Home | Imprint | This part of the site doesn't use cookies.