hydratePriceRule example

->addOrderBy('price.from', 'ASC')
            ->setParameter(':products', $ids, Connection::PARAM_INT_ARRAY)
            ->setParameter(':customerGroup', $customerGroup->getKey());

        $this->fieldHelper->addPriceTranslation($query$context);

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

        $prices = [];
        foreach ($data as $row) {
            $productNumber = (string) $row['number'];
            $prices[$productNumber][] = $this->priceHydrator->hydratePriceRule($row);
        }

        return $prices;
    }
}


    /** * Hydrates the data result of the cheapest price query. * This function uses the normally hydrate function of this class * and adds additionally the product unit information to the price. * * @return PriceRule */
    public function hydrateCheapestPrice(array $data)
    {
        $price = $this->hydratePriceRule($data);
        $translation = $this->productHydrator->getProductTranslation($data);
        $data = array_merge($data$translation);

        $unit = $this->unitHydrator->hydrate($data);
        $price->setUnit($unit);

        return $price;
    }

    /** * @param array $data * * @return PriceGroup */
Home | Imprint | This part of the site doesn't use cookies.