跨境电商博客

Zen Cart 二次开发:为产品添加自定义产品管理字段

例如:为产品添加一个名为products_family字段。

1.在zencart数据库products表内添加products_family字段(列名为products_family)
ALTER TABLE `products` ADD `products_family` INT NOT NULL AFTER `products_status`

2.修改文件脚本
2-1.admin/includes/modules/products/collect_info.php
找到:
if (isset($_GET[‘pID’]) && empty($_POST)) {
$product = $db->Execute(“select pd.products_name, pd.products_description, pd.products_url,

//(添加)And add the following line:
p.products_family, //(just look at the pattern)

要在产品页面显示该字段内容:
< ?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_family', ($pInfo->products_family == 0 ? 0 : $pInfo->products_family)); ?>

2-2.为该字段设置产品页显示标题,例如:Product Family :(结果)
admin/includes/languages/english/product.php 内添加:define(‘TEXT_PRODUCTS_FAMILY’,’Product Family :’);
页面显示调用:< ?php echo TEXT_PRODUCTS_FAMILY; ?>

2-3.admin/includes/modules/update_product.php 更新产品语句
找到:
$sql_data_array = array(‘products_quantity’ => $products_quantity,
下加一行:
‘products_family’ => zen_db_prepare_input($_POST[‘products_family’]),

设置好字段值之后,可以用插件批量导入字段值
https://yyme.net/post/2058.html

赞 (0) 打赏

评论 0

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏