Detail example


    public function internalCreate(array $data, ProductModel $article)
    {
        $variant = new Detail();
        $variant->setKind(2);
        $variant->setArticle($article);

        $data = $this->prepareData($data$article$variant);

        $variant->fromArray($data);

        $this->getManager()->persist($variant);

        return $variant;
    }

    
if (!\array_key_exists('taxId', $detail)) {
                throw new NotFoundException('details.taxId');
            }

            // If no order number was specified for the details we use the one from the order if there is one             if ((!\array_key_exists('number', $detail) || $detail['number'] !== $params['number'])
                && !empty($params['number'])) {
                $detail['number'] = $params['number'];
            }

            $detailModel = new Detail();
            $detailModel->fromArray($detail);

            $status = $this->getContainer()->get(ModelManager::class)->find(DetailStatus::class$detail['statusId']);
            if (!$status) {
                throw new NotFoundException(sprintf('DetailStatus by id %s not found', $detail['statusId']));
            }
            $detailModel->setStatus($status);
            unset($detail['statusId']);

            $tax = $this->getContainer()->get(ModelManager::class)->find(Tax::class$detail['taxId']);
            if (!$tax) {
                
/** * Helper function which converts the passed data for the main variant of the product. * * @param array<string, mixed> $data * * @return array<string, mixed> */
    public function prepareMainDetail(array $data, ProductModel $article)
    {
        $detail = $article->getMainDetail();
        if (!$detail) {
            $detail = new Detail();
            $detail->setKind(1);
            $detail->setArticle($article);
            $article->setMainDetail($detail);
        }

        if (empty($data['mainDetail'])) {
            $data['mainDetail'] = [];
        }

        $data['mainDetail'] = $this->getVariantResource()->prepareMainVariantData($data['mainDetail']$article$detail);

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