Zen-Cart给产品参数添加新字段
2010-12-29 14:04
162 查看
这篇文章介绍怎么样为普通产品添加一个新属性。
1、首先考虑你要添加一个什么样的 属性到你的产品,在这个例子中添加两个属性:[guarantee-time]和[color]。
2、在数据库管理界面 (如:phpmyadmin)中找到表[products],或者表的前缀加[products],为这个表添加两个字段: [products_guarantee] 和[products_color] :
3、编辑文件 [collect_info.php](在目录/admin/includes/modules/product/下)
(1)在最开始的地方有一 个变量参数设置,添加你的字段到它们的最后:
(2) 在下边有一个数据库查询:
添加你的字段在 [from ...] 部分的前边,并且字段前添加:
(3)现在添加输入框到产品表单中(在450行附近,具体位置自己 看情况定):
如果是编辑器的话需要在adminincludesfunctionsgeneral.php文件里面添加一个声明
4、 编辑文件 [preview_info.php] (在目录 /admin/includes/modules/product/下)
在第10行 左右,找到变量[$product]的定义. 像上边3.2中的一样添加查询字段:
5、 编辑 [update_product.php] (在目录/admin/includes/modules/下)
在20行左右找 到$sql_data_array变量那个的定义. 在最后一行的[);] 前边添加新字段.
6、 编辑 [main_template_vars.php] (在目录/includes/modules/pages/product_info/下)
在 第40行左右找到变量[$sql]的定义,像3.2中一样添加新字段的查询:
7、 最后一步:在产品信息中显示。
编辑[tpl_product_info_display.php'](在目录/includes /templates/你的模板/templates/下)
你可以把下边的代码添加到你认为合适的显示位置
OK,希望你一切顺利!
1、首先考虑你要添加一个什么样的 属性到你的产品,在这个例子中添加两个属性:[guarantee-time]和[color]。
2、在数据库管理界面 (如:phpmyadmin)中找到表[products],或者表的前缀加[products],为这个表添加两个字段: [products_guarantee] 和[products_color] :
1 2 | ALTERTABLE`zencart_products`ADD`products_guarantee`INTNOTNULL,ADD`products_color`VARCHAR( 32 )NOTNULL; |
(1)在最开始的地方有一 个变量参数设置,添加你的字段到它们的最后:
1 | 'products_guarantee'=>'0','products_color'=>''); |
1 | set[$product = $db->Execute("...] |
1 | select ......., p.products_guarantee, p.products_color from .... |
1 23 | <tr> <tdclass =main>Guarantee Time (in months) </tdclass><tdclass =main>< ?phpecho zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_guarantee', $pInfo->products_guarantee, zen_set_field_length(TABLE_PRODUCTS, 'products_guarantee')); ?> </tdclass></tr> <tr> <tdclass =main>Color </tdclass><tdclass =main>< ?phpecho zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_color', $pInfo->products_color, zen_set_field_length(TABLE_PRODUCTS, 'products_color')); ?> </tdclass></tr> |
4、 编辑文件 [preview_info.php] (在目录 /admin/includes/modules/product/下)
在第10行 左右,找到变量[$product]的定义. 像上边3.2中的一样添加查询字段:
1 | select......., p.products_guarantee, p.products_colorfrom.... |
在20行左右找 到$sql_data_array变量那个的定义. 在最后一行的[);] 前边添加新字段.
1 2 | $sql_data_array= ..........'products_guarantee'=> zen_db_prepare_input($_POST['products_guarantee']),'products_color'=> zen_db_prepare_input($_POST['products_color']) ); |
在 第40行左右找到变量[$sql]的定义,像3.2中一样添加新字段的查询:
1 2 | select......., p.products_guarantee, p.products_colorfrom.... |
编辑[tpl_product_info_display.php'](在目录/includes /templates/你的模板/templates/下)
你可以把下边的代码添加到你认为合适的显示位置
1 23 | echo$product_info->fields['products_guarantee']; echo$product_info->fields['products_color']; |
相关文章推荐
- Zen-Cart给产品添加新字段
- zen cart页面头部添加多语言切换
- magento添加多个产品到购物车(Add multiple products to cart )
- Zen-cart里迁移产品数据的方法
- zen-cart中一些常用的后台设置参数
- magento产品成功添加到购物车后跳转到不同页面 添加 add to cart 按钮
- 将Zen-Cart首页产品以TabControl的形式显示
- 将Zen-Cart首页产品以TabControl的形式显示
- zencart zencart产品分享到twitter、facebook 经典代码
- zen-cart后台邮箱参数设置
- zen-cart 如何在Define Page Editer中添加新的页面?
- 如何添加产品详情的一些参数
- Zen-cart产品页面随机调用Wordpress文章
- Bigcommerce:cart页面和wishlist页面添加产品的SKU
- zen-cart 目录产品显示控制
- ZEN_CART_如何添加自定义页面
- WordPress安装到zen-cart产品页中
- weblogic为同一domain下的不同server添加不同参数
- 如何将自定义的搜索参数便捷的添加到js方式的bootstrap table的参数中
- zencart Fatal error: Allowed memory size of 33554432 bytes exhausted的解决办法