0

i add new fields into custom options template like.

enter image description here

i add Details field following http://magento.ikantam.com/qa/how-add-custom-attributes-custom-options tutorial.

i want to Display the Details field value on Product View page. Like in this tutorial say for display the values to front side rewrite 'Mage_Catalog_Block_Product_View_Options_Type_Select' this class but is not working.

Thanks

in this function i add "firstmenu" class into ul tag

public function getValuesHtml()
{
    $_option = $this->getOption();
    $configValue = $this->getProduct()->getPreconfiguredValues()->getData('options/' . $_option->getId());
    $store = $this->getProduct()->getStore();

    if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN
        || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) {
        $require = ($_option->getIsRequire()) ? ' required-entry' : '';
        $extraParams = '';
        $select = $this->getLayout()->createBlock('core/html_select')
            ->setData(array(
                'id' => 'select_'.$_option->getId(),
                'class' => $require.' product-custom-option'
            ));
        if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN) {
            $select->setName('options['.$_option->getid().']')
                ->addOption('', $this->__('-- Please Select --'));
        } else {
            $select->setName('options['.$_option->getid().'][]');
            $select->setClass('multiselect'.$require.' product-custom-option');
        }
        foreach ($_option->getValues() as $_value) {
            $priceStr = $this->_formatPrice(array(
                'is_percent'    => ($_value->getPriceType() == 'percent'),
                'pricing_value' => $_value->getPrice(($_value->getPriceType() == 'percent'))
            ), false);
            $select->addOption(
                $_value->getOptionTypeId(),
                $_value->getTitle() . ' ' . $priceStr . '',
                array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
            );
        }
        if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) {
            $extraParams = ' multiple="multiple"';
        }
        if (!$this->getSkipJsReloadPrice()) {
            $extraParams .= ' onchange="opConfig.reloadPrice()"';
        }
        $select->setExtraParams($extraParams);

        if ($configValue) {
            $select->setValue($configValue);
        }

        return $select->getHtml();
    }

    if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO
        || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX
        ) {
        $selectHtml = '<ul id="options-'.$_option->getId().'-list" class="firstmenu options-list">';
        $require = ($_option->getIsRequire()) ? ' validate-one-required-by-name' : '';
        $arraySign = '';
        switch ($_option->getType()) {
            case Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO:
                $type = 'radio';
                $class = 'radio';
                if (!$_option->getIsRequire()) {
                    $selectHtml .= '<li><input type="radio" id="options_' . $_option->getId() . '" class="'
                        . $class . ' product-custom-option" name="options[' . $_option->getId() . ']"'
                        . ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"')
                        . ' value="" checked="checked" /><span class="label"><label for="options_'
                        . $_option->getId() . '">' . $this->__('None') . '</label></span></li>';
                }
                break;
            case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX:
                $type = 'checkbox';
                $class = 'checkbox';
                $arraySign = '[]';
                break;
        }
        $count = 1;
        foreach ($_option->getValues() as $_value) {
            $count++;

            $priceStr = $this->_formatPrice(array(
                'is_percent'    => ($_value->getPriceType() == 'percent'),
                'pricing_value' => $_value->getPrice($_value->getPriceType() == 'percent')
            ));

            $htmlValue = $_value->getOptionTypeId();
            if ($arraySign) {
                $checked = (is_array($configValue) && in_array($htmlValue, $configValue)) ? 'checked' : '';
            } else {
                $checked = $configValue == $htmlValue ? 'checked' : '';
            }

            $selectHtml .= '<li>' . '<input type="' . $type . '" class="' . $class . ' ' . $require
                . ' product-custom-option"'
                . ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"')
                . ' name="options[' . $_option->getId() . ']' . $arraySign . '" id="options_' . $_option->getId()
                . '_' . $count . '" value="' . $htmlValue . '" ' . $checked . ' price="'
                . $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false) . '" />'
                . '<span class="label"><label for="options_' . $_option->getId() . '_' . $count . '">'
                . $_value->getTitle() . ' ' . $priceStr . '</label></span>';
            if ($_option->getIsRequire()) {
                $selectHtml .= '<script type="text/javascript">' . '$(\'options_' . $_option->getId() . '_'
                . $count . '\').advaiceContainer = \'options-' . $_option->getId() . '-container\';'
                . '$(\'options_' . $_option->getId() . '_' . $count
                . '\').callbackFunction = \'validateOptionsCallback\';' . '</script>';
            }
            $selectHtml .= '</li>';
        }
        $selectHtml .= '</ul>';

        return $selectHtml;
    }
}

1 Answer 1

1

Basically this block section is Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select

and your blog template file of this block is

app/design/adminhtml/default/default/template/ikantam/catalog/product/edit/options/type/select.phtml and it code may like

app/design/adminhtml/default/default/template//catalog/product/edit/options/type/select.phtml.

As per as your question upgradation :

block:

Mage_Catalog_Block_Product_View_Options_Type_Select it rendered the details ta product page and it template file is

template:

app\design\frontend\YourPackage\YourTemplate\template\catalog\product\view\options\type\select.phtml
12
  • Hey Amit, i want to display the Details Values to Front side Admin is working i done this step but now how to Display on product view page. May 28, 2015 at 11:12
  • Hey when i changed 'Mage_Catalog_Block_Product_View_Options_Type_Select' block it dosen't effect i checked after clearing cache or reindex but not display my cahnges. May 28, 2015 at 11:56
  • please show code?...
    – Amit Bera
    May 28, 2015 at 11:59
  • please check your compiler,is enable or not or memacached etc
    – Amit Bera
    May 28, 2015 at 12:03
  • Hey Amit, i edit my answer please check i add class into ul tag 'class="firstmenu options-list"' May 28, 2015 at 12:04

Your Answer

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

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