findByOrderNumber example

// 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;
            }

            // saves the model             $this->get('models')->persist($premiumModel);
            $this->get('models')->flush();

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