tags:

views:

15

answers:

0

hello ,

i inserted a code in the "product/view.phtml" page which inserts a custom option for the product when the page is loaded but it is not displaying the custom option on first load even if the custom option has been already inserted , but displays only after refreshing the page the code i used is :

       $_helper = $this->helper('catalog/output');
       $_product = $this->getProduct();
  //echo $this->getProduct()->getId();
  //exit();
   if(!$this->hasOptions()){    
   $options =   array(
        'type'      => 'radio',
        'is_require'    => 1,
        'price'     => 0,
        'price_type'    => 'fixed'
      );

$values = array(
        array(
            'title'     => 'Magento Development Basics',
            'price'     => 10,
            'price_type'    => 'fixed',
        ),

        array(
            'title'     => 'Intermediate Magento Development',
            'price'     => 20,
            'price_type'    => 'fixed',
        ),

        array(
            'title'     => 'Advanced Magento Development',
            'price'     => 40,
            'price_type'    => 'fixed'
        )
     );
try {
    $helper = Mage::helper('custom_options')->setCustomOption($this->getProduct()->getId(), 'Magento Development Tutorial', $options, $values);
} catch (Exception $e) {        
    echo $e->getMessage();
}

}

i placed this code on the top of the "product/view.phtml" page

any help will be appreciated ...

Thanx,