displayFromPrice example



    private function loadPrices(Criteria $criteria, ProductSearchResult $result, ShopContextInterface $context): void
    {
        $cheapestPriceData = $this->variantCheapestPriceGateway->getList($result->getProducts()$context$context->getCurrentCustomerGroup()$criteria);

        foreach ($result->getProducts() as $product) {
            $number = $product->getNumber();

            if (!\array_key_exists($number$cheapestPriceData)) {
                $cheapestPriceRule = $product->getPriceRules()[0];
                $displayFromPrice = $product->displayFromPrice();
            } else {
                $cheapestPriceRule = $cheapestPriceData[$number]['price'];
                $displayFromPrice = $cheapestPriceData[$number]['different_price_count'] > 1;
            }

            if ($product->isPriceGroupActive()) {
                $cheapestPriceRule = $this->calculatePriceGroupDiscounts($product$cheapestPriceRule$context);
            }

            $product->setCheapestPriceRule($cheapestPriceRule);
            $this->priceCalculationService->calculateProduct($product$context);

            
 $product->getCategories());

        return \in_array($context->getShop()->getCategory()->getId()$ids);
    }

    private function allowBuyInListing(ListProduct $product): bool
    {
        return !$product->hasConfigurator()
            && $product->isAvailable()
            && $product->getUnit()
            && $product->getUnit()->getMinPurchase() <= 1
            && !$product->displayFromPrice();
    }

    /** * @param ListProduct[] $products * * @return array<int> */
    private function getManufacturerCoverIds(array $products): array
    {
        $ids = array_map(function DListProduct $product) {
            if ($product->getManufacturer() instanceof Manufacturer) {
                

        $cheapestPrice = $product->getListingPrice();

        $promotion = $this->getListProductData($product);
        $promotion = array_merge($promotion$this->convertProductPriceStruct($cheapestPrice));

        if ($product->getPriceGroup()) {
            $promotion['pricegroupActive'] = true;
            $promotion['pricegroupID'] = $product->getPriceGroup()->getId();
        }

        if ($product->displayFromPrice()) {
            $promotion['priceStartingFrom'] = $promotion['price'];
        }

        if ($product->getCover()) {
            $promotion['image'] = $this->convertMediaStruct($product->getCover());
        }

        if ($product->getVoteAverage()) {
            $promotion['sVoteAverage'] = $this->convertVoteAverageStruct($product->getVoteAverage());
        }

        
$result = new ProductSearchResult(
            [$product->getNumber() => $product],
            1,
            [],
            $criteria,
            $this->contextService->getShopContext()
        );

        $service->updatePrices($criteria$result$this->contextService->getShopContext());

        if ($product->displayFromPrice()) {
            $data['priceStartingFrom'] = $product->getListingPrice()->getCalculatedPrice();
        }

        $data['price'] = $product->getListingPrice()->getCalculatedPrice();

        return $this->legacyEventManager->fireArticleByIdEvents($data$this);
    }

    /** * Creates different links for the product like `add to basket`, `add to note`, `view detail page`, ... * * @param int $categoryId * @param bool $addNumber * * @return array */
Home | Imprint | This part of the site doesn't use cookies.