setCheapestUnitPrice example

$this->parseAttributes($product->getAttributes())
            );

            $product->setCreatedAt(null);
            $product->setUpdatedAt(null);

            $product->setReleaseDate(null);
            $product->setPrices(null);
            $product->setPriceRules(null);
            $product->setCheapestPriceRule(null);
            $product->setCheapestPrice(null);
            $product->setCheapestUnitPrice(null);
            $product->setAvailableCombinations(null);
            $product->setFullConfiguration(null);
            $product->resetStates();

            if (!$this->isValid($shop$product)) {
                continue;
            }
            $result[$number] = $product;
        }

        return $result;
    }

            $rule = clone $product->getCheapestPriceRule();
            $product->setCheapestPrice(
                $this->calculateCheapestAvailablePrice($product$rule$context)
            );

            /** * Calculation without considering min purchase */
            $rule = clone $product->getCheapestPriceRule();
            $product->setCheapestUnitPrice(
                $this->calculatePriceStruct($rule$tax$context)
            );
        }

        // Add state to the product which can be used to check if the prices are already calculated.         $product->addState(ListProduct::STATE_PRICE_CALCULATED);
    }

    /** * Calculates the cheapest price considering the variant min purchase */
    
$product->setManufacturerNumber($listProduct->getManufacturerNumber());
        $product->setMetaTitle($listProduct->getMetaTitle());
        $product->setTemplate($listProduct->getTemplate());
        $product->setHasConfigurator($listProduct->hasConfigurator());
        $product->setSales($listProduct->getSales());
        $product->setHasEsd($listProduct->hasEsd());
        $product->setEsd($listProduct->getEsd());
        $product->setIsPriceGroupActive($listProduct->isPriceGroupActive());
        $product->setBlockedCustomerGroupIds($listProduct->getBlockedCustomerGroupIds());
        $product->setVoteAverage($listProduct->getVoteAverage());
        $product->setHasAvailableVariant($listProduct->hasAvailableVariant());
        $product->setCheapestUnitPrice($listProduct->getCheapestUnitPrice());
        $product->setFallbackPriceCount($listProduct->getFallbackPriceCount());
        $product->setCustomerPriceCount($listProduct->getCustomerPriceCount());

        foreach ($listProduct->getAttributes() as $name => $attribute) {
            $product->addAttribute($name$attribute);
        }

        foreach ($listProduct->getStates() as $state) {
            $product->addState($state);
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.