setListPrice example

UnitCollection $units,
        ReferencePriceDto $reference,
        int $quantity = 1
    ): QuantityPriceDefinition {
        $price = $this->getPriceValue($prices$context);

        $taxId = $product->get('taxId');
        $definition = new QuantityPriceDefinition($price$context->buildTaxRules($taxId)$quantity);
        $definition->setReferencePriceDefinition(
            $this->buildReferencePriceDefinition($reference$units)
        );
        $definition->setListPrice(
            $this->getListPrice($prices$context)
        );
        $definition->setRegulationPrice(
            $this->getRegulationPrice($prices$context)
        );

        return $definition;
    }

    private function getPriceValue(PriceCollection $price, SalesChannelContext $context): float
    {
        

            $data['taxRules']
        );

        $self = new self(
            (float) $data['price'],
            new TaxRuleCollection($taxRules),
            \array_key_exists('quantity', $data) ? $data['quantity'] : 1
        );

        $self->setIsCalculated(\array_key_exists('isCalculated', $data) ? $data['isCalculated'] : false);
        $self->setListPrice(isset($data['listPrice']) ? (float) $data['listPrice'] : null);
        $self->setRegulationPrice(isset($data['regulationPrice']) ? (float) $data['regulationPrice'] : null);

        return $self;
    }

    public function jsonSerialize(): array
    {
        $data = parent::jsonSerialize();
        $data['type'] = $this->getType();

        return $data;
    }
$price->setNet((float) $row['net']);
            $price->setLinked((bool) $row['linked']);

            if (isset($row['listPrice'])) {
                $list = clone $blueprint;

                $list->setCurrencyId($row['currencyId']);
                $list->setGross((float) $row['listPrice']['gross']);
                $list->setNet((float) $row['listPrice']['net']);
                $list->setLinked((bool) $row['listPrice']['linked']);

                $price->setListPrice($list);
            }

            if (isset($row['regulationPrice'])) {
                $regulation = clone $blueprint;

                $regulation->setCurrencyId($row['currencyId']);
                $regulation->setGross((float) $row['regulationPrice']['gross']);
                $regulation->setNet((float) $row['regulationPrice']['net']);
                $regulation->setLinked((bool) $row['regulationPrice']['linked']);

                $price->setRegulationPrice($regulation);
            }
break;
            }
        }

        return $this->buildPriceDefinition($price$quantity);
    }

    private function buildPriceDefinition(CalculatedPrice $price, int $quantity): QuantityPriceDefinition
    {
        $definition = new QuantityPriceDefinition($price->getUnitPrice()$price->getTaxRules()$quantity);
        if ($price->getListPrice() !== null) {
            $definition->setListPrice($price->getListPrice()->getPrice());
        }

        if ($price->getReferencePrice() !== null) {
            $definition->setReferencePriceDefinition(
                new ReferencePriceDefinition(
                    $price->getReferencePrice()->getPurchaseUnit(),
                    $price->getReferencePrice()->getReferenceUnit(),
                    $price->getReferencePrice()->getUnitName()
                )
            );
        }

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