网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 网站建设 > ZenCart
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 218.2.66.119
Old 2009-12-08, 10:59 AM
topvip topvip is offline
超级版主
 
Join Date: 2006-01-04
Posts: 1206
topvip 正向着好的方向发展
Default Zen Cart中给产品添加新字段

在网上找到一篇英文文章,为了方便,特翻译成中文。
原文地址:http://www.zen-cart.com/forum/showthread.php?t=57924

这篇文章介绍怎么样为普通产品添加一个新属性。
1、首先考虑你要添加一个什么样的属性到你的产品,在这个例子中添加两个属性:[guarantee-time]和[color]。

2、在数据库管理界面(如hpmyadmin)中找到表[products],或者表的前缀加[products],为这个表添加两个字段: [products_guarantee] 和[products_color] :
ALTER TABLE `zencart_products` ADD `products_guarantee` INT NOT NULL , ADD `products_color` VARCHAR( 32 ) NOT NULL;

3、编辑文件 [collect_info.php](在目录/admin/includes/modules/product/下)
(1)在最开始的地方有一个变量参数设置,添加你的字段到它们的最后:
'products_guarantee' => '0', 'products_color' => '' );

(2)在下边有一个数据库查询:
set [$product = $db->Execute("...]
添加你的字段在 [from ...] 部分的前边,并且字段前添加[p.]:
select ......., p.products_guarantee, p.products_color from ....

(3)现在添加输入框到产品表单中(在450行附近,具体位置自己看情况定):
Code:
<tr>
<td class="main">Guarantee Time (in months)</td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_guarantee', $pInfo->products_guarantee, zen_set_field_length(TABLE_PRODUCTS, 'products_guarantee')); ?></td>
</tr><tr>
<td class="main">Color</td>
<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_input_field('products_color', $pInfo->products_color, zen_set_field_length(TABLE_PRODUCTS, 'products_color')); ?></td>
</tr>
4、编辑文件 [preview_info.php] (在目录 /admin/includes/modules/product/下)
在第10行左右,找到变量[$product]的定义. 像上边3.2中的一样添加查询字段:
select ......., p.products_guarantee, p.products_color from ....

5、编辑 [update_product.php] (在目录/admin/includes/modules/下)
在20行左右找到$sql_data_array变量那个的定义. 在最后一行的[);] 前边添加新字段.
$sql_data_array = .......... 'products_guarantee' => zen_db_prepare_input($_POST['products_guarantee']), 'products_color' => zen_db_prepare_input($_POST['products_color']) );

6、编辑 [main_template_vars.php] (在目录/includes/modules/pages/product_info/下)
在第40行左右找到变量[$sql]的定义,像3.2中一样添加新字段的查询:
select ……., p.products_guarantee, p.products_color from ….
7、最后一步:在产品信息中显示。
编辑[tpl_product_info_display.php'](在目录/includes/templates/你的模板/templates/下)
你可以把下边的代码添加到你认为合适的显示位置
Code:
<?php fields['products_guarantee']; ?> and <?php fields['products_color']; ?>
OK,希望你一切顺利!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
有关Zen Cart的一些常用操作 yahoo ZenCart 0 2009-12-01 09:36 PM
How to Install an Zen Cart Template topvip ZenCart 0 2009-08-23 05:35 PM
Zen Cart 中文版 全新安装 教程 topvip ZenCart 5 2009-08-23 05:24 PM
zen cart 添加自定义页面涉及文件及对应目录 car ZenCart 0 2009-08-21 01:18 AM
zen cart定制 zen cart二次开发 car ZenCart 0 2009-08-21 01:11 AM

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:07 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.