getVariantPrice example

if ($product->getPriceGroup()) {
            $data = array_merge(
                $data,
                [
                    'pricegroupActive' => $product->isPriceGroupActive(),
                    'pricegroupID' => $product->getPriceGroup()->getId(),
                    'pricegroup_attributes' => $product->getPriceGroup()->getAttributes(),
                ]
            );
        }

        $variantPrice = $product->getVariantPrice();
        $data = array_merge($data$this->convertProductPriceStruct($variantPrice));
        $data['referenceprice'] = $variantPrice->getCalculatedReferencePrice();
        $data['pricegroup'] = $variantPrice->getCustomerGroup()->getKey();

        if (\count($product->getPrices()) > 1) {
            foreach ($product->getPrices() as $price) {
                $data['sBlockPrices'][] = $this->convertPriceStruct(
                    $price
                );
            }
        }

        
public function getList(array $numbers, ShopContextInterface $context): array
    {
        $products = $this->listProductService->getList($numbers$context);
        $propertySets = $this->propertyService->getList($products$context);
        $covers = $this->variantCoverService->getList($products$context);
        $details = [];
        foreach ($products as $product) {
            $arrayProduct = $this->legacyStructConverter->convertListProductStruct($product);

            if ($product->hasConfigurator()) {
                $variantPrice = $product->getVariantPrice();
                $arrayProduct['referenceprice'] = $variantPrice->getCalculatedReferencePrice();
            }

            if (isset($covers[$product->getNumber()])) {
                $arrayProduct['image'] = $this->legacyStructConverter->convertMediaStruct($covers[$product->getNumber()]);
            }

            if ($product->hasProperties() && isset($propertySets[$product->getNumber()])) {
                $propertySet = $propertySets[$product->getNumber()];
                $arrayProduct['sProperties'] = $this->legacyStructConverter->convertPropertySetStruct($propertySet);
                $arrayProduct['filtergroupID'] = $propertySet->getId();
                
Home | Imprint | This part of the site doesn't use cookies.