在“管理"部分的“捆绑商品"选项中添加新字段 [英] Add new field in bundle item option in admin section

查看:101
本文介绍了在“管理"部分的“捆绑商品"选项中添加新字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是magento的新手.我正在从管理部分创建捆绑产品.添加捆绑商品时,只有标题字段可提供信息,但我需要为描述添加一个字段,就像我创建捆绑一样用于计算机的项目,但我需要显示有关它的描述.

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 .

请帮助.my,要求添加新的字段描述以及捆绑商品选项中的标题. 任何帮助将不胜感激.

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

推荐答案

您可以通过编辑app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml和很少的数据库更改来向magento捆绑产品添加额外的字段.

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.

首先,我们必须使用instraller脚本将自定义字段添加到数据库中的catalog_product_option_type_value表中

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();

然后将文件复制到位置app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml

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

app\design\adminhtml\default\default\template\companyname\catalog\product\edit\options\type\select.phtml.覆盖核心文件

重写:"Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select"块,并通过指示我们的phtml文件替换其中的构造函数文件

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);
}

在OptionTemplateSelect变量中的

open companyname/catalog/product/edit/options/type/select.phtml ile中,我们在'sort order'字段下添加以下行:

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>'+

将OptionTemplateSelectRow标签添加到变量:

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

在:'getOptionValues()'方法中,循环:foreach($ option-> getValues()as $ _value){

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

在变量:$ value及其值:$_value->getYourCustomField();

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

为了使新属性出现在前端,请重写该类:Mage_Catalog_Block_Product_View_Options_Type_Select并将新添加的属性添加到该类中.但是请注意,根据自定义选项的类型,会生成不同类型的html.

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

这篇关于在“管理"部分的“捆绑商品"选项中添加新字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆