{"id":59188,"date":"2025-04-23T16:33:30","date_gmt":"2025-04-23T08:33:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/59188\/"},"modified":"2025-04-23T16:33:30","modified_gmt":"2025-04-23T08:33:30","slug":"ecshop%e9%a6%96%e9%a1%b5%e5%92%8c%e5%88%86%e7%b1%bb%e9%a1%b5%e8%b0%83%e7%94%a8%e5%95%86%e5%93%81%e8%b4%a7%e5%8f%b7%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/59188\/","title":{"rendered":"ecshop\u9996\u9875\u548c\u5206\u7c7b\u9875\u8c03\u7528\u5546\u54c1\u8d27\u53f7\u7684\u89e3\u51b3\u529e\u6cd5"},"content":{"rendered":"<p>\u627e\u5230\u7f51\u7ad9\u6839<span>\u76ee\u5f55<\/span>\u4e0b\u9762\u7684includes\u76ee\u5f55\uff0c\u6253\u5f00\u4e4b\u540e\u627e\u5230lib_goods.php<span>\u6587\u4ef6<\/span>\uff0c\u6253\u5f00\u4e4b\u540e\u627e\u5230<\/p>\n<blockquote><p>\n  \/**<br \/>\n <br \/> * \u83b7\u5f97<br \/>\n <span>\u63a8\u8350<\/span><br \/>\n <span>\u5546\u54c1<\/span><br \/>\n <br \/> *<br \/>\n <br \/> * @access public<br \/>\n <br \/> * @param string $type \u63a8\u8350\u7c7b\u578b\uff0c\u53ef\u4ee5\u662f best, new, hot, promote<br \/>\n <br \/> * @return array<br \/>\n <br \/> *\/<br \/>\n <br \/> function get_recommend_goods($type = &#8221;, $cats = &#8221;)<br \/>\n <br \/> {<br \/>\n <br \/> if (!in_array($type, array(&#8216;best&#8217;, &#8216;new&#8217;, &#8216;hot&#8217;, &#8216;promote&#8217;)))<br \/>\n <br \/> {<br \/>\n <br \/> return array();<br \/>\n <br \/> } <\/p>\n<p> $time = gmtime(); <\/p>\n<p> $order_type = 0; <\/p>\n<p> \/* \u53d6\u5f97\u6bcf\u4e00\u9879\u7684<br \/>\n <span>\u6570\u91cf<\/span>\u9650\u5236 *\/<br \/>\n <br \/> $type2lib = array(&#8216;best&#8217;=&gt;&#8217;recommend_best&#8217;, &#8216;new&#8217;=&gt;&#8217;recommend_new&#8217;, &#8216;hot&#8217;=&gt;&#8217;recommend_hot&#8217;, &#8216;promote&#8217;=&gt;&#8217;recommend_promotion&#8217;);<br \/>\n <br \/> $num = get_library_number($type2lib[$type]); <\/p>\n<p> $sql = &#8216;SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, &#8216; .<br \/>\n <br \/> &#8220;IFNULL(mp.user_price, g.shop_price * &#8216;$_SESSION[discount]&#8217;) AS shop_price, &#8220;.<br \/>\n <br \/> &#8220;promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, &#8221; .<br \/>\n <br \/> &#8220;g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd &#8221; .<br \/>\n <br \/> &#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;goods&#8217;) . &#8216; AS g &#8216; .<br \/>\n <br \/> &#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;brand&#8217;) . &#8216; AS b ON b.brand_id = g.brand_id &#8216; .<br \/>\n <br \/> &#8220;LEFT JOIN &#8221; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;member_price&#8217;) . &#8221; AS mp &#8220;.<br \/>\n <br \/> &#8220;ON mp.goods_id = g.goods_id AND mp.user_rank = &#8216;$_SESSION[user_rank]&#8217; &#8220;.<br \/>\n <br \/> &#8216;WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 &#8216;;\n<\/p><\/blockquote>\n<p> 1\u3002\u4e0a\u9762\u8fd9\u6bb5<span>\u4ee3\u7801<\/span>\uff0c\u5728\u5728goods_id \u540e\u6dfb\u52a0 goods_sn,\u6539\u540e\u5982\u4e0b<\/p>\n<blockquote><p>\n  $sql = &#8216;SELECT g.goods_id, g.goods_sn, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, &#8216; .<br \/>\n <br \/> &#8220;IFNULL(mp.user_price, g.shop_price * &#8216;$_SESSION[discount]&#8217;) AS shop_price, &#8220;.<br \/>\n <br \/> &#8220;promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, &#8221; .<br \/>\n <br \/> &#8220;g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd &#8221; .<br \/>\n <br \/> &#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;goods&#8217;) . &#8216; AS g &#8216; .<br \/>\n <br \/> &#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;brand&#8217;) . &#8216; AS b ON b.brand_id = g.brand_id &#8216; .<br \/>\n <br \/> &#8220;LEFT JOIN &#8221; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;member_price&#8217;) . &#8221; AS mp &#8220;.<br \/>\n <br \/> &#8220;ON mp.goods_id = g.goods_id AND mp.user_rank = &#8216;$_SESSION[user_rank]&#8217; &#8220;.<br \/>\n <br \/> &#8216;WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 &#8216;;\n<\/p><\/blockquote>\n<p> 2.\u5728\u540e\u9762\u4e0d\u8fdc\u5904 \u6dfb\u52a0\u4ee3\u7801$goods[$idx][&#8216;goods_sn&#8217;]&nbsp; &nbsp;&nbsp;&nbsp;= $row[&#8216;goods_sn&#8217;];\uff0c\u6539\u540e\u5982\u4e0b<\/p>\n<blockquote><p>\n <br \/> $goods[$idx][&#8216;id&#8217;]&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;= $row[&#8216;goods_id&#8217;];<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$goods[$idx][&#8216;name&#8217;]&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;= $row[&#8216;goods_name&#8217;];<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$goods[$idx][&#8216;brief&#8217;]&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;= $row[&#8216;goods_brief&#8217;];<br \/>\n <br \/> &nbsp;&nbsp;$goods[$idx][&#8216;goods_sn&#8217;]&nbsp; &nbsp;&nbsp;&nbsp;= $row[&#8216;goods_sn&#8217;];<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$goods[$idx][&#8216;brand_name&#8217;]&nbsp; &nbsp;= $row[&#8216;brand_name&#8217;];<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$goods[$idx][&#8216;goods_style_name&#8217;]&nbsp; &nbsp;= add_style($row[&#8216;goods_name&#8217;],$row[&#8216;goods_name_style&#8217;]);\n<\/p><\/blockquote>\n<p> 3.\u63a5\u4e0b\u6765\u5728\u4f60\u4f7f\u7528\u7684\u98ce\u683c\u7684library\u4e2d\uff0c\u4fee\u6539recommend_best.lbi\uff0c\u589e\u52a0{$goods.goods_sn}\u5728\u9700\u8981\u663e\u793a\u4f4d\u7f6e\u5c31\u53ef\u4ee5\u4e86\u3002recommend_new.lbi\uff0crecommend_hot.lbi\u90fd\u662f\u4e00\u6837\u3002<\/p>\n<p> 4.<span>\u5206\u7c7b<\/span>\u9875\u7684<span>\u89e3\u51b3<\/span><span>\u529e\u6cd5<\/span>\u3002\u5176\u5b9e\u8ddf\u4e0a\u9762\u7684\u4e00\u6837\uff0c\u5927\u5bb6\u5148\u5230\u6839\u76ee\u5f55\u4e0b\u627e\u5230category.php\uff0c\u6253\u5f00\u627e\u5230 <br \/> &nbsp;<\/p>\n<blockquote><p>\n  function category_get_goods($children, $brand, $min, $max, $ext, $size, $page, $sort, $order)<br \/>\n <br \/> {<br \/>\n <br \/> &nbsp; &nbsp; $display = $GLOBALS[&#8216;display&#8217;];<br \/>\n <br \/> &nbsp; &nbsp; $where = &#8220;g.is_on_sale = 1 AND g.is_alone_sale = 1 AND &#8220;.<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8220;g.is_delete = 0 AND ($children OR &#8221; . get_extension_goods($children) . &#8216;)&#8217;; <\/p>\n<p> &nbsp; &nbsp; if ($brand &gt; 0)<br \/>\n <br \/> &nbsp; &nbsp; {<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$where .=&nbsp;&nbsp;&#8220;AND g.brand_id=$brand &#8220;;<br \/>\n <br \/> &nbsp; &nbsp; } <\/p>\n<p> &nbsp; &nbsp; if ($min &gt; 0)<br \/>\n <br \/> &nbsp; &nbsp; {<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$where .= &#8221; AND g.shop_price &gt;= $min &#8220;;<br \/>\n <br \/> &nbsp; &nbsp; } <\/p>\n<p> &nbsp; &nbsp; if ($max &gt; 0)<br \/>\n <br \/> &nbsp; &nbsp; {<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$where .= &#8221; AND g.shop_price &lt;= $max &#8220;;<br \/>\n <br \/> &nbsp; &nbsp; } <\/p>\n<p> &nbsp; &nbsp; \/* \u83b7\u5f97\u5546\u54c1<br \/>\n <span>\u5217\u8868<\/span> *\/<br \/>\n <br \/> &nbsp; &nbsp; $sql = &#8216;SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, &#8216; .<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &#8220;IFNULL(mp.user_price, g.shop_price * &#8216;$_SESSION[discount]&#8217;) AS shop_price, g.promote_price, g.goods_type, &#8221; .<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &#8216;g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img &#8216; .<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;goods&#8217;) . &#8216; AS g &#8216; .<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;member_price&#8217;) . &#8216; AS mp &#8216; .<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &#8220;ON mp.goods_id = g.goods_id AND mp.user_rank = &#8216;$_SESSION[user_rank]&#8217; &#8221; .<br \/>\n <br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&#8220;WHERE $where $ext ORDER BY $sort $order&#8221;;\n<\/p><\/blockquote>\n<p> \u5728g.goods_id\u5b57\u6bb5\u540e\u9762\u589e\u52a0g.goods_sn\uff0c\u540c\u65f6\u5728\u4e0b\u9762\u4e0d\u8fdc\u5904\u8ddf\u4e0a\u9762\u7684\u76f8\u4f3c\uff0c\u589e\u52a0$arr[$row[&#8216;goods_id&#8217;]][&#8216;goods_sn&#8217;]&nbsp; &nbsp;&nbsp; &nbsp;= $row[&#8216;goods_sn&#8217;];<span>\u7a0b\u5e8f<\/span>\u90e8\u5206\u4fee\u6539\u4e86\uff0c\u63a5\u4e0b\u6765\u5927\u5bb6\u81ea\u5df1\u53bb\u4fee\u6539\u76f8\u5e94\u98ce\u683c\u7684<span>\u6a21\u677f<\/span>\uff0c\u589e\u52a0{$goods.goods_sn}\u5728\u9700\u8981\u663e\u793a\u4f4d\u7f6e\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u641c\u7d22\u9875\u662f\u4e00\u6837\u7684\u9053\u7406\uff0c\u53ea\u8981\u4fee\u6539search.dwt\u548csearch.php\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u627e\u5230\u7f51\u7ad9\u6839\u76ee\u5f55\u4e0b\u9762\u7684includes\u76ee\u5f55\uff0c\u6253\u5f00\u4e4b\u540e\u627e\u5230lib_goods.php\u6587\u4ef6\uff0c\u6253\u5f00\u4e4b\u540e\u627e\u5230 \/** * \u83b7\u5f97 \u63a8\u8350 \u5546\u54c1 * * @access public * @param string $type \u63a8\u8350\u7c7b\u578b\uff0c\u53ef\u4ee5\u662f best, new, hot, promote * @return array *\/ function get_recommend_goods($type = &#8221;, $cats = &#8221;) { if (!in_array($type, array(&#8216;best&#8217;, &#8216;new&#8217;, &#8216;hot&#8217;, &#8216;promote&#8217;))) { return array(); } $time = gmtime(); $order_type = 0; \/* \u53d6\u5f97\u6bcf\u4e00\u9879\u7684 \u6570\u91cf\u9650\u5236 *\/ $type2lib = array(&#8216;best&#8217;=&gt;&#8217;recommend_best&#8217;, &#8216;new&#8217;=&gt;&#8217;recommend_new&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-59188","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=59188"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59188\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=59188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=59188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=59188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}