{"id":60089,"date":"2025-04-24T11:39:08","date_gmt":"2025-04-24T03:39:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60089\/"},"modified":"2025-04-24T11:39:08","modified_gmt":"2025-04-24T03:39:08","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8ecshop%e9%a6%96%e9%a1%b5%e8%b0%83%e7%94%a8%e6%8c%87%e5%ae%9a%e5%88%86%e7%b1%bb%e7%9a%84%e7%83%ad%e9%94%80%e3%80%81%e6%8e%a8%e8%8d%90%e3%80%81%e6%96%b0-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60089\/","title":{"rendered":"\u5982\u4f55\u5728ecshop\u9996\u9875\u8c03\u7528\u6307\u5b9a\u5206\u7c7b\u7684\u70ed\u9500\u3001\u63a8\u8350\u3001\u65b0"},"content":{"rendered":"<p>&nbsp;\u627e\u5230ecshop\u7684<span style=\"font-family: Verdana, Helvetica, Arial, sans-serif;font-size: 14px;line-height: 22px\">includes\/lib_goods.php\uff0c\u4fee\u6539\u65b9\u6cd5\u5982\u4e0b<\/span><\/p>\n<p><span style=\"font-family: Verdana, Helvetica, Arial, sans-serif;font-size: 14px;line-height: 22px\">\u4ee5\u628aSQL\u8bed\u53e5\u6539\u4e00\u4e0b\uff0c\u4e0ecategory\u8868\u5173\u8054\u5373\u53ef\u5c06 <\/span><\/p>\n<ol>\n<li>$sql =&nbsp;&nbsp;&#8216;SELECT g.goods_id,g.goods_name, g.goods_name_style,<\/li>\n<li>g.market_price, g.shop_price AS org_price, g.promote_price, &#8216; .<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u6539\u4e3a   <\/p>\n<ol>\n<li>&nbsp;&nbsp;$sql =&nbsp;&nbsp;&#8216;SELECT g.goods_id,g.cat_id,c.parent_id,g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, &#8216; .<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u518d\u5728   <\/p>\n<ol>\n<li>&#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;brand&#8217;) . &#8216; AS b ON b.brand_id = g.brand_id &#8216; .<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u4e0b\u52a0\u4e00\u53e5   <\/p>\n<ol>\n<li>&#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;category&#8217;) . &#8216; AS c ON c.cat_id = g.cat_id &#8216; .<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u7136\u540e\u5c06   <\/p>\n<ol>\n<li>if (!empty($cats))<\/li>\n<li>&nbsp; &nbsp; {<\/li>\n<li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$sql .= &#8221; AND (&#8221; . $cats . &#8221; OR &#8221; . get_extension_goods($cats) .&#8221;)&#8221;;<\/li>\n<li>&nbsp; &nbsp; }<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u6539\u4e3a   <\/p>\n<ol>\n<li>if (!empty($cats))<\/li>\n<li>&nbsp; &nbsp; {<\/li>\n<li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;$sql .= &#8221; AND (c.parent_id =&#8221; . $cats. &#8221; OR &#8221; . get_extension_goods($cats) .&#8221;)&#8221;;<\/li>\n<li>&nbsp; &nbsp; }<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u8fd9\u4e2a\u662f\u548c\u5206\u7c7b\u8868\u5efa\u7acb\u5173\u8054\uff0c\u8c03\u51fa\u5546\u54c1\u6240\u5728\u5206\u7c7b\u7684\u4e0a\u7ea7\u5206\u7c7b<br \/>\n<br \/> \u7136\u540e\u5728index.php\u4e2d smarty   <\/p>\n<ol>\n<li>$smarty-&gt;assign(&#8216;<strong><font style=\"line-height: normal\">chot<\/font><\/strong>_goods_35&#8242;,&nbsp; &nbsp;get_category_recommend_goods(&#8216;hot&#8217;,&#8217;35&#8217;));&nbsp; &nbsp;&nbsp;&nbsp;\/\/\u6307\u5b9a\u5206\u7c7b\u4e0b\u7684\u70ed\u9500\u5546\u54c1<\/li>\n<\/ol>\n<p><em>\u590d\u5236\u4ee3\u7801<\/em>  \u6ce8\u610f\u8fd9\u4e2a35\u662f\u4e00\u7ea7\u5206\u7c7b\u7684ID\uff0c\u7136\u540e\u5728\u6a21\u677f\u4e2d\u8c03\u7528\u5373\u53ef<br \/>\n<br \/> &lt;!&#8211;{foreach from=$<br \/>\n<strong><font style=\"line-height: normal\">chot<\/font><\/strong>_goods_35 item=goods}&#8211;&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;div style=&#8221;padding-top: 8px;&#8221; class=&#8221;new-tr&#8221;&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;a target=&#8221;_blank&#8221; href=&#8221;{$goods.url}&#8221;&gt;&lt;img width=&#8221;116&#8243; height=&#8221;130&#8243; border=&#8221;0&#8243; alt=&#8221;{$goods.name|escape:html}&#8221; src=&#8221;{$goods.thumb}&#8221;&gt;&lt;\/a&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;div class=&#8221;right&#8221;&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;a target=&#8221;_blank&#8221; href=&#8221;{$goods.url}&#8221;&gt;{$goods.name|escape:html}&lt;\/a&gt;&lt;br&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;span style=&#8221;color: rgb(102, 102, 102); text-decoration: line-through;&#8221;&gt;\u5e02\u573a\u4ef7\uff1a{$goods.market_price}&lt;\/span&gt;&lt;br&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; \u7279\u5356\u4ef7\uff1a&lt;span style=&#8221;color: rgb(255, 0, 0);&#8221;&gt;{$goods.shop_price}&lt;\/span&gt;&lt;br&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;span class=&#8221;font-gmm&#8221;&gt;&lt;a&nbsp;&nbsp;href=&#8221;javascript:addToCart({$goods.id})&#8221;&gt;\u7acb\u5373\u62a2\u8d2d&lt;\/a&gt;&lt;\/span&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;\/div&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;span class=&#8221;new-line&#8221;&gt;&lt;\/span&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;\/div&gt;<br \/>\n<br \/> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;!&#8211;{\/foreach}&#8211;&gt;<br \/>\n<br \/> \u540c\u7406\uff0c\u65b0\u54c1\uff0c\u63a8\u8350\u90fd\u53ef\u4ee5\u8c03\uff0c\u53ea\u8981\u628ahot\u6539\u4e3anew \u6216\u8005best\u5c31\u53ef\u4ee5\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;\u627e\u5230ecshop\u7684includes\/lib_goods.php\uff0c\u4fee\u6539\u65b9\u6cd5\u5982\u4e0b \u4ee5\u628aSQL\u8bed\u53e5\u6539\u4e00\u4e0b\uff0c\u4e0ecategory\u8868\u5173\u8054\u5373\u53ef\u5c06 $sql =&nbsp;&nbsp;&#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; . \u590d\u5236\u4ee3\u7801 \u6539\u4e3a &nbsp;&nbsp;$sql =&nbsp;&nbsp;&#8216;SELECT g.goods_id,g.cat_id,c.parent_id,g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, &#8216; . \u590d\u5236\u4ee3\u7801 \u518d\u5728 &#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;brand&#8217;) . &#8216; AS b ON b.brand_id = g.brand_id &#8216; . \u590d\u5236\u4ee3\u7801 \u4e0b\u52a0\u4e00\u53e5 &#8216;LEFT JOIN &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;category&#8217;) . &#8216; AS c ON [&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-60089","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60089","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=60089"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60089\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}