Add new field in bundle item option in admin section

做~自己de王妃 提交于 2019-12-12 01:39:58

问题


I am new bie in magento.I am creating a bundle product from admin section .when I add the bundle item there is only the title field for information but I need to add one more field for the description like I created a bundle item for computers but I need to show description about it .

Please help .my requirement is to add new field for description along with the title in bundle item option. any help will be appreciated .


回答1:


you can add extra field to magento bundle products by editing app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml and few database changes.

EDIT: first we have to add our custom field to catalog_product_option_type_value table in the database, using a instraller script

    <?php

/* @var $installer Mage_Core_Model_Resource_Setup */

$installer = $this;

$installer->getConnection()

    ->addColumn($installer->getTable('catalog/product_option_type_value'), 'your_custom_field_name’, 'VARCHAR(128) NULL');

$installer->endSetup();

then copy the file in location app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml

to app\design\adminhtml\default\default\template\companyname\catalog\product\edit\options\type\select.phtml. override the core file

Rewrite: ‘Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select’ block and replace constructor file in it by indicating our phtml file

    public function __construct()
{
    parent::__construct();
    $this->setTemplate('companyname/catalog/product/edit/options/type/select.phtml');
    $this->setCanEditPrice(true);
    $this->setCanReadPrice(true);
}

open companyname/catalog/product/edit/options/type/select.phtml ile in OptionTemplateSelect varilable in tag we add the line: under 'sort order' field

'<th class="type-title"><?php echo Mage::helper('catalog')->__('your_custom_field_name') ?></th>'+

Add OptionTemplateSelectRow tag to the variable:

'<td><input type="text" class="input-text select-type-details" id="product_option_{{id}}_select_{{select_id}}_title" name="product[options][{{id}}][values][{{select_id}}][your_custom_field_name]" value="{{your_custom_field_name}}">{{checkboxScopeTitle}}</td>'+

now check in backend you should see the custom field by now. to make it required you can add required-entry class to above input field

now for retrieve values from database re-write the block:

Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option

In: 'getOptionValues()' method, cycle: foreach ($option->getValues() as $_value) {

add new key: 'your_custom_field_name' to the variable: $value and the value for it: $_value->getYourCustomField();

now custom field will appear in database

In order for the new attribute to appear on the frontend rewrite the class: Mage_Catalog_Block_Product_View_Options_Type_Select and add the newly added attribute to it. But be aware that depending on the type of Custom Options there different kinds of htmls generate.

please refer this article for more details



来源:https://stackoverflow.com/questions/24087599/add-new-field-in-bundle-item-option-in-admin-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!