Magento 1.9 – Show Price Range of Simple Product with Custom Option

custom-optionsmagento-1.9price

I am working on Magento 1.9.2.4 and I have to show some simple products on the home page but their price should be displayed in the format of Price: minimum_price To maximum_price instead of base price.

Suppose I have a product in the admin panel with name Gwyneth Basket

  • Its base price 0
  • And Under the custom option, I create a drop-down Like

enter image description here

Now in the frontend, I have to show Gwyneth Basket product like

enter image description here

It working as desired on category page using This Reference But how do I achieve this on custom templates.

Thank You

Best Answer

        $product = Mage::getModel("catalog/product")->load(1); //product id 1
        $i = 1;
        $array = array();
        echo "<pre>";
        foreach ($product->getOptions() as $o) {
            $values = $o->getValues();
            foreach ($values as $v) {
                $array[] = $v->getPrice();
            }
            $i++;
            echo "<br/>";

        }
        sort($array); 
        $max = count($array) - 1 ;
        echo "<pre>";
        print_r($array);
        echo $minPrice = $array[0];
        echo $maxPrice = $array[$max];

        if(empty($array)){
            $price = $product->getPrice();
        }

        echo "Base Price" . $price;

Work Fine for me.

Related Topic