hydrateCheapestPrice example

$this->fieldHelper->addUnitTranslation($query$context);
        $this->fieldHelper->addProductTranslation($query$context);
        $this->fieldHelper->addVariantTranslation($query$context);
        $this->fieldHelper->addPriceTranslation($query$context);

        $data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        $prices = [];
        foreach ($data as $row) {
            $product = $row['__price_articleID'];
            $prices[$product] = $this->priceHydrator->hydrateCheapestPrice($row);
        }

        return $prices;
    }

    /** * Pre selection of the cheapest prices ids. * * @param BaseProduct[] $products * * @return array<int> */
$mainQuery->setParameter(':customerGroup', $context->getCurrentCustomerGroup()->getKey())
            ->setParameter(':fallbackCustomerGroup', $context->getFallbackCustomerGroup()->getKey())
            ->setParameter(':variants', $variantIds, Connection::PARAM_INT_ARRAY)
            ->setParameter(':priceGroupCustomerGroup', $customerGroup->getId());

        $data = $mainQuery->execute()->fetchAll(PDO::FETCH_ASSOC);

        $prices = [];
        foreach ($data as $row) {
            $product = (string) $row['__variant_ordernumber'];
            $prices[$product]['price'] = $this->priceHydrator->hydrateCheapestPrice($row);
            $prices[$product]['price']->setCustomerGroup($customerGroup);

            $prices[$product]['different_price_count'] = (int) $row['__different_price_count'];
        }

        return $prices;
    }

    /** * @deprecated - Will be private in Shopware 5.8 * * @return string */
Home | Imprint | This part of the site doesn't use cookies.