getArticleDetail example

$product->setInStock($product->getInStock() + $detail->getQuantity());
            $this->entityManager->persist($product);
        }
    }

    /** * Returns the product of the product position */
    protected function getProductFromDetail(OrderDetail $detail): ?ProductDetail
    {
        if (\in_array($detail->getMode()[0, 1], true)) {
            if ($detail->getArticleDetail() && $detail->getArticleDetail()->getId()) { // After the detail got removed, the association to the product detail does not exist anymore.                 return $detail->getArticleDetail();
            } elseif ($detail->getArticleNumber()) {
                return $this->getProductByNumber($detail->getArticleNumber());
            }
        }

        return null;
    }

    /** * Returns a product by the ordernumber */
$esd = $this->get('models')->getRepository(Esd::class)->find($esdId);
        if (!$esd) {
            $this->View()->assign([
                'success' => false,
                'message' => sprintf('ESD by id %s not found', $esdId),
            ]);

            return;
        }

        $freeSerialsCount = $this->getFreeSerialCount($esdId);
        $variant = $esd->getArticleDetail();
        $variant->setInStock($freeSerialsCount);

        $esd->fromArray($this->Request()->getPost());
        $this->getManager()->flush();

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

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