0

I am able to get Bundle and Configurable Regular Price of Product. But Special Price there is no min max available.

Below is code which I tried for regular configurable price but same is not working for special Price

    $product = $this->modelProduct->load(745);
    $configPrice=$product->getPriceInfo()->getPrice('regular_price');
    echo '=>'. $configPrice->getMinRegularAmount();// For min price
    echo '=>'. $configPrice->getMaxRegularAmount();// For max price
1

Try this function for Special Price Range (it works for me)

public function getSpecialPriceRange($product)
    {
        $specialChildProductPrice = [];
        $specialChildProduct = $this->configurableProduct->getUsedProducts($product);
        foreach ($specialChildProduct as $child) {
            $specialPrice = $child->getSpecialPrice();
            if ($specialPrice !=0 and !is_null($specialPrice)) {
                $specialPrice = number_format($specialPrice, 2, '.', '');
                $specialChildProductPrice[] = $specialPrice;
            }
        }
        if (count($specialChildProductPrice)==0) {
            return '';
        }
        $maxInt = max($specialChildProductPrice);
        $minInt = min($specialChildProductPrice);
        if ($maxInt == 0) {
            return '';
        }
        $max = $this->pricingHelper->currencyByStore($maxInt);
        $min = $this->pricingHelper->currencyByStore($minInt);


        if ($min==$max) {
            return $this->getPriceRender($product, "$min", '', 'special-price');
        } else {
            return $this->getPriceRender($product, "$min - $max", '', 'special-price');
        }
    }
  • 1
    Where you have used this function? – Magecode May 28 '19 at 13:04
  • can you provide more details about using this function? If it's part of a module, can you post the other module files? – zekia Jun 13 '19 at 10:40
  • @zekia what are you trying to achieve? Submit a question if you having issue on what you developing. – Ylgen Guxholli Jun 14 '19 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.