getDetailRepository example

/** * Event listener function of the product store of the backend module. * * @retrun void */
    public function deleteProductAction()
    {
        $id = \is_null($this->Request()->getParam('Detail_id')) ? null : (int) $this->Request()->getParam('Detail_id');

        /** @var Detail $variant */
        $variant = $this->getDetailRepository()->find($id);
        if (!\is_object($variant)) {
            $this->View()->assign([
                'success' => false,
            ]);
        } else {
            $articleResource = new ArticleResource();
            $articleResource->setManager($this->get(ModelManager::class));

            if ($variant->getKind() == 1) {
                $articleResource->delete($variant->getArticle()->getId());
            } else {
                

    public function getIdFromNumber($number)
    {
        if (empty($number)) {
            throw new ParameterMissingException('id');
        }

        $productVariant = $this->getDetailRepository()->findOneBy(['number' => $number]);

        if (!$productVariant instanceof Detail) {
            throw new NotFoundException(sprintf('Product by number "%s" not found', $number));
        }

        return $productVariant->getArticle()->getId();
    }

    /** * Convenience method to get a product by number * * @param string $number * * @return array|ProductModel */
Home | Imprint | This part of the site doesn't use cookies.