2

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

2

1 Answer 1

1
        $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.

4
  • Thank You :) Its working as desired. One question if how do I show base price if custom option is not available? Dec 30, 2016 at 12:56
  • Please check my updated answer.
    – Ajay Patel
    Dec 30, 2016 at 13:11
  • you need to just set one condition for base price if custom price array is empty set base price
    – Ajay Patel
    Dec 30, 2016 at 13:12
  • ThankYou @AjayPatel :) Happy Coding.... Dec 30, 2016 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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