setPseudoPrice example

ListProduct $product,
        PriceRule $priceRule,
        ShopContextInterface $context
    ): Price {
        if ($priceRule->getUnit() instanceof Unit) {
            $priceRule->setPrice(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getPrice()
            );
            $priceRule->getUnit()->setPurchaseUnit(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getUnit()->getPurchaseUnit()
            );
            $priceRule->setPseudoPrice(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getPseudoPrice()
            );

            $priceRule->setRegulationPrice(
                $priceRule->getUnit()->getMinPurchase() * $priceRule->getRegulationPrice()
            );
        }

        $tax = $context->getTaxRule($product->getTax()->getId());
        if (!$tax instanceof Tax) {
            throw new StructNotFoundException(Tax::class$product->getTax()->getId());
        }
foreach ($discounts as $discount) {
            $rule = clone $reference;

            $percent = (100 - $discount->getPercent()) / 100;

            $price = $reference->getPrice() * $percent;

            $pseudo = $reference->getPseudoPrice();

            $rule->setPrice($price);

            $rule->setPseudoPrice($pseudo);

            $rule->setFrom($discount->getQuantity());

            $rule->setCustomerGroup($customerGroup);

            $rule->setTo(null);
            if ($previous) {
                $previous->setTo($rule->getFrom() - 1);
            }

            $previous = $rule;
            
/** * @return PriceRule */
    public function hydratePriceRule(array $data)
    {
        $price = new PriceRule();

        $price->setId((int) $data['__price_id']);
        $price->setFrom((int) $data['__price_from']);
        $price->setPrice((float) $data['__price_price']);
        $price->setPseudoPrice((float) $data['__price_pseudoprice']);
        $price->setRegulationPrice((float) $data['__price_regulation_price']);

        if (strtolower($data['__price_to']) === 'beliebig') {
            $price->setTo(null);
        } else {
            $price->setTo((int) $data['__price_to']);
        }

        if (isset($data['__priceAttribute_id'])) {
            $this->attributeHydrator->addAttribute($price$data, 'priceAttribute');
        }

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