加个商品信息字段

2016-07-07 15:16 来源:www.chinab4c.com 作者:ecshop专家

贴个代码~~~
准备添加的字段信息:
  1. 商品信息
  2. 50 介质media
  3. 20 主演star
  4. 20 作者author
  5. 20 导演director
  6. 20 语言language
  7. 20 字幕title
  8. 30 出版号 isrc
  9. 20 产地madein
  10. 120 版权提供 provide
  11. 30 版权号provideno
  12. 30 引进号importno
  13. 120 出版publish
复制代码


修改结构
  1. ALTER TABLE `前缀_goods`
  2. ADD `media` varchar(50) NOT NULL default '',
  3. ADD `star` varchar(20) NOT NULL default '',
  4. ADD `author` varchar(20) NOT NULL default '',
  5. ADD `director` varchar(20) NOT NULL default '',
  6. ADD `language` varchar(20) NOT NULL default '',
  7. ADD `title` varchar(20) NOT NULL default '',
  8. ADD `isrc` varchar(30) NOT NULL default '',
  9. ADD `madein` varchar(20) NOT NULL default '',
  10. ADD `provide` varchar(120) NOT NULL default '',
  11. ADD `provideno` varchar(30) NOT NULL default '',
  12. ADD `importno` varchar(30) NOT NULL default '',
  13. ADD `publish` varchar(120) NOT NULL default '';
复制代码


goods_info.htm注释中是添加的
  1. <!-- start goods form -->
  2. <div class="tab-div">
  3. <!-- tab bar -->
  4. <div id="tabbar-div">
  5. <p>
  6. <span class="tab-front" id="general-tab">{$lang.tab_general}</span>
  7. <!-- modify by xsy -->
  8. <span class="tab-back" id="goodsinfo-tab">{$lang.tab_goodsinfo}</span>
  9. <span
  10. class="tab-back" id="detail-tab">{$lang.tab_detail}</span><span
  11. class="tab-back" id="mix-tab">{$lang.tab_mix}</span>{if $goods_type_list}<span
  12. class="tab-back" id="properties-tab">{$lang.tab_properties}</span>{/if}<span
  13. class="tab-back" id="gallery-tab">{$lang.tab_gallery}</span><span
  14. class="tab-back" id="linkgoods-tab">{$lang.tab_linkgoods}</span><span
  15. class="tab-back" id="groupgoods-tab">{$lang.tab_groupgoods}</span><span
  16. class="tab-back" id="article-tab">{$lang.tab_article}</span>
  17. </p>
  18. </div>
复制代码

  1. <!-- 商品信息 modify by xsy -->
  2. <table width="90%" id="goodsinfo-table" style="display:none">
  3. <td class="label">{$lang.lab_media}</td>
  4. <td><input type="text" name="media" value="{$goods.media}" size="10" /></td>
  5. </tr>
  6. <tr>
  7. <td class="label">{$lang.lab_star}</td>
  8. <td><input type="text" name="star" value="{$goods.star}" size="15" /></td>
  9. </tr>
  10. <tr>
  11. <td class="label">{$lang.lab_author}</td>
  12. <td><input type="text" name="author" value="{$goods.author}" size="15" /></td>
  13. </tr>
  14. <tr>
  15. <td class="label">{$lang.lab_director}</td>
  16. <td><input type="text" name="director" value="{$goods.director}" size="20" /></td>
  17. </tr>
  18. <tr>
  19. <td class="label">{$lang.lab_language}</td>
  20. <td><input type="text" name="language" value="{$goods.language}" size="15" /></td>
  21. </tr>
  22. <tr>
  23. <td class="label">{$lang.lab_title}</td>
  24. <td><input type="text" name="title" value="{$goods.title|escape}" size="15" /></td>
  25. </tr>
  26. <tr>
  27. <td class="label">{$lang.lab_isrc}</td>
  28. <td><input type="text" name="isrc" value="{$goods.isrc|escape}" size="20" /></td>
  29. </tr>
  30. <tr>
  31. <td class="label">{$lang.lab_madein}</td>
  32. <td><input type="text" name="madein" value="{$goods.madein|escape}" size="15" /></td>
  33. </tr>
  34. <tr>
  35. <td class="label">{$lang.lab_provide}</td>
  36. <td><input type="text" name="provide" value="{$goods.provide|escape}" size="15" /></td>
  37. </tr>
  38. <tr>
  39. <td class="label">{$lang.lab_provideno}</td>
  40. <td><input type="text" name="provideno" value="{$goods.provideno|escape}" size="15" /></td>
  41. </tr>
  42. <tr>
  43. <td class="label">{$lang.lab_importno}</td>
  44. <td><input type="text" name="importno" value="{$goods.importno|escape}" size="15" /></td>
  45. </tr>
  46. <tr>
  47. <td class="label">{$lang.lab_publish}</td>
  48. <td><input type="text" name="publish" value="{$goods.publish|escape}" size="20" /></td>
  49. </tr>
  50. </table>
复制代码


相关语言 goods.php

  1. /* 附加商品信息 modify by xsy */
  2. $_LANG['tab_goodsinfo'] = '商品信息';
  3. $_LANG['lab_media'] = '介质:';
  4. $_LANG['lab_star'] = '主演:';
  5. $_LANG['lab_author'] = '作者:';
  6. $_LANG['lab_director'] = '导演:';
  7. $_LANG['lab_language'] = '语言:';
  8. $_LANG['lab_title'] = '字幕:';
  9. $_LANG['lab_isrc'] = '出版号:';
  10. $_LANG['lab_madein'] = '产地:';
  11. $_LANG['lab_provide'] = '版权提供:';
  12. $_LANG['lab_provideno'] = '版权号:';
  13. $_LANG['lab_importno'] = '引进号:';
  14. $_LANG['lab_publish'] = '出版:';
复制代码


主要代码修改

  1. /* 入库 */
  2. if ($is_insert)
  3. {
  4. // modify by xsy
  5. $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_sn, " .
  6. "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
  7. "promote_start, promote_end, goods_img, goods_thumb, original_img, keywords, goods_brief, seller_note, " .
  8. "goods_weight, goods_number, warn_number, integral, is_best, is_new, is_hot, " .
  9. "is_on_sale, is_alone_sale, can_handsel, goods_desc, add_time, last_update, goods_type, cycle_img, ".
  10. "media, star, author, director, language, title, isrc, madein, provide, importno, publish)" .
  11. "VALUES ('$_POST[goods_name]', '$goods_sn', '$_POST[cat_id]', " .
  12. "'$_POST[brand_id]', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
  13. "'$promote_start', '$promote_end', '$goods_img', '$goods_thumb', '$original_img', '$_POST[keywords]', ".
  14. "'$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number', '$warn_number', '$_POST[integral]', ".
  15. "'$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', '$can_handsel', ".
  16. "'$_POST[goods_desc]', '" . time() . "', '". time() ."', '$goods_type', '$cycle_img', ".
  17. "'$goods_media','$goods_star','$goods_author','$goods_directory','$goods_language','$goods_title','$goods_isrc', ".
  18. "'$goods_provide','$goods_importno','$goods_publish')";
  19. }
  20. else
  21. {
  22. $sql = "UPDATE " . $ecs->table('goods') . " SET " .
  23. "goods_name = '$_POST[goods_name]', " .
  24. "goods_sn = '$goods_sn', " .
  25. "cat_id = '$_POST[cat_id]', " .
  26. "brand_id = '$_POST[brand_id]', " .
  27. "shop_price = '$shop_price', " .
  28. "market_price = '$market_price', " .
  29. "is_promote = '$is_promote', " .
  30. "promote_price = '$promote_price', " .
  31. "promote_start = '$promote_start', " .
  32. "promote_end = '$promote_end', ";
  33. if ($goods_img)
  34. {
  35. $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";
  36. }
  37. if ($goods_thumb)
  38. {
  39. $sql .= "goods_thumb = '$goods_thumb', ";
  40. }
  41. // modify by xsy
  42. $sql .= "keywords = '$_POST[keywords]', " .
  43. "goods_brief = '$_POST[goods_brief]', " .
  44. "seller_note = '$_POST[seller_note]', " .
  45. "goods_weight = '$goods_weight'," .
  46. "goods_number = '$goods_number', " .
  47. "warn_number = '$warn_number', " .
  48. "integral = '$_POST[integral]', " .
  49. "is_best = '$is_best', " .
  50. "is_new = '$is_new', " .
  51. "is_hot = '$is_hot', " .
  52. "is_on_sale = '$is_on_sale', " .
  53. "is_alone_sale = '$is_alone_sale', " .
  54. "can_handsel = '$can_handsel', " .
  55. "goods_desc = '$_POST[goods_desc]', " .
  56. "last_update = '". time() ."', ".
  57. "goods_type = '$goods_type', " .
  58. "cycle_img = '$cycle_img' ," .
  59. "media = '$goods_media' ," .
  60. "star = '$goods_star' ," .
  61. "author = '$goods_author' ," .
  62. "director = '$goods_director' ," .
  63. "language = '$goods_language' ," .
  64. "title = '$goods_title' ," .
  65. "isrc = '$isrc' ," .
  66. "madein = '$madein' ," .
  67. "provide = '$provide' ," .
  68. "provideno = '$provideno' ," .
  69. "importno = '$importno' ," .
  70. "publish = '$publish' " .
  71. "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
  72. }
复制代码


修改后的效果:
1.jpg

回答:
谢谢!学习了!

学习了 以后能用得着

首先说,过程写的很清楚,改的很好。

不过我觉得EC的属性功能完全可以实现你这个需求。

好厉害哇

我要是只添加一个字段呢,是不是比这个更简单,我想给商品添加一个副标题!!

2.72的属性功能已经很完善的了

这个可以奥,改改数据库!!!!

成功写入了,但是,怎么调用呢!!!!