{"id":199037,"date":"2025-05-03T09:48:40","date_gmt":"2025-05-03T01:48:40","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199037\/"},"modified":"2025-05-03T09:48:40","modified_gmt":"2025-05-03T01:48:40","slug":"%e5%9c%a8ecshop%e5%85%a8%e9%83%a8%e5%93%81%e7%89%8c%e9%a1%b5%e5%ae%9e%e7%8e%b0%e5%88%86%e9%a1%b5%e6%8d%a2%e9%a1%b5%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199037\/","title":{"rendered":"\u5728ECSHOP\u5168\u90e8\u54c1\u724c\u9875\u5b9e\u73b0\u5206\u9875\u6362\u9875\u529f\u80fd"},"content":{"rendered":"<p>\u6700\u8fd1\u770b\u5230\u6709\u670b\u53cb\u5728\u8bba\u575b\u95ee\u5230\u8fc7\u6b64\u7c7b\u95ee\u9898\uff0c\u6240\u4ee5\u62bd\u7a7a\u5199\u4e86\u4e0b\u6587\u3002<br \/> \u201c\u5728\u5168\u90e8\u54c1\u724c\u9875\u5b9e\u73b0\u5206\u9875\u6362\u9875\u529f\u80fd\u201d\uff0c\u5bf9\u5546\u54c1\u54c1\u724c\u8f83\u591a\u7684\u670b\u53cb\u4e5f\u8bb8\u4f1a\u6709\u5e2e\u52a9\u3002<\/p>\n<p>1\u3001\u6253\u5f00brand.php<br \/> \u627e\u5230 <br \/> if (empty($brand_id))<br \/> {<br \/> \u518d\u627e\u5230<br \/> exit();<br \/> }<\/p>\n<p>\u5c06\u8fd9\u4e24\u8005\u4e4b\u95f4\u7684\u4ee3\u7801\u5168\u90e8\u66ff\u6362\u4e3a\u4e0b\u9762\u4ee3\u7801 <\/p>\n<table cellspacing=\"0\" cellpadding=\"5\" style=\"border-right: #cccccc 1px solid;border-top: #cccccc 1px solid;background: #f7f7f7;border-left: #cccccc 1px solid;width: 90%;border-bottom: #cccccc 1px solid\">\n<tbody>\n<tr>\n<td><font>assign_template();<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $position = assign_ur_here(&#8221;, $_LANG[&#8216;all_brand&#8217;]);<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $smarty-&gt;assign(&#8216;page_title&#8217;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $position[&#8216;title&#8217;]);&nbsp;&nbsp;&nbsp; \/\/ \u9875\u9762\u6807\u9898<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $smarty-&gt;assign(&#8216;ur_here&#8217;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $position[&#8216;ur_here&#8217;]);&nbsp; \/\/ \u5f53\u524d\u4f4d\u7f6e<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $smarty-&gt;assign(&#8216;categories&#8217;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get_categories_tree()); \/\/ \u5206\u7c7b\u6811<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $smarty-&gt;assign(&#8216;helps&#8217;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get_shop_help());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ \u7f51\u5e97\u5e2e\u52a9<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $smarty-&gt;assign(&#8216;top_goods&#8217;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; get_top10());&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ \u9500\u552e\u6392\u884c<br \/> &nbsp; <br \/> &nbsp; $sql = &#8220;SELECT count(*) as brand_count from ( select b.brand_id &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;FROM &#8221; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;brand&#8217;) . &#8220;AS b, &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;goods&#8217;) . &#8221; AS g &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;WHERE g.brand_id = b.brand_id AND is_show = 1 &#8221; .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8221; AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;GROUP BY b.brand_id ) AS gb&#8221;;<br \/> &nbsp; $brand_count=$GLOBALS[&#8216;db&#8217;]-&gt;getOne($sql);&nbsp; \/\/\u54c1\u724c(\u542b\u6709\u5546\u54c1\u7684)\u6570\u91cf <br \/> &nbsp;&nbsp; $page&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = !empty($_REQUEST[&#8216;page&#8217;])&nbsp; &amp;&amp; intval($_REQUEST[&#8216;page&#8217;])&nbsp; &gt; 0 ? intval($_REQUEST[&#8216;page&#8217;])&nbsp; : 1;<br \/> &nbsp;&nbsp; $size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 3;<br \/> &nbsp;&nbsp; $max_page = ($brand_count&gt; 0) ? ceil($brand_count \/ $size) : 1;<br \/> &nbsp;&nbsp; if ($page &gt; $max_page)&nbsp; {$page = $max_page;}<br \/> &nbsp;&nbsp; $start=($page &#8211; 1) * $size;&nbsp;&nbsp; <br \/> &nbsp; $sql = &#8220;SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, COUNT(*) AS goods_num, IF(b.brand_logo &gt; &#8221;, &#8216;1&#8217;, &#8216;0&#8217;) AS tag &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;FROM &#8221; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;brand&#8217;) . &#8220;AS b, &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;goods&#8217;) . &#8221; AS g &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;WHERE g.brand_id = b.brand_id AND is_show = 1 &#8221; .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8221; AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 &#8220;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;GROUP BY b.brand_id HAVING goods_num &gt; 0 ORDER BY tag DESC, b.sort_order ASC limit $start,$size&#8221;;<br \/> &nbsp; <br \/> &nbsp; $row = $GLOBALS[&#8216;db&#8217;]-&gt;getAll($sql);<br \/> &nbsp; foreach ($row AS $key =&gt; $val)<br \/> &nbsp; {<br \/> &nbsp;&nbsp; $row[$key][&#8216;url&#8217;] = build_uri(&#8216;brand&#8217;, array(&#8216;cid&#8217; =&gt; $cat, &#8216;bid&#8217; =&gt; $val[&#8216;brand_id&#8217;]), $val[&#8216;brand_name&#8217;]);<br \/> &nbsp;&nbsp; $row[$key][&#8216;brand_desc&#8217;] = htmlspecialchars($val[&#8216;brand_desc&#8217;],ENT_QUOTES);<br \/> &nbsp; }<br \/> &nbsp; $pager[&#8216;search&#8217;] = array( );<br \/> &nbsp; $pager = get_pager(&#8216;brand.php&#8217;, $pager[&#8216;search&#8217;], $brand_count, $page, $size);<br \/> &nbsp; $pager[&#8216;display&#8217;] = $display;<br \/> &nbsp; $smarty-&gt;assign(&#8216;pager&#8217;, $pager);<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $smarty-&gt;assign(&#8216;brand_list&#8217;, $row);&nbsp; <br \/> &nbsp;&nbsp;&nbsp; $smarty-&gt;display(&#8216;brand_list.dwt&#8217;);<\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> 2\u3001\u6253\u5f00 \u6a21\u677f\u6587\u4ef6 brand_list.dwt<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; \u5728\u4f60\u60f3\u8981\u663e\u793a\u6362\u9875\u4fe1\u606f\u7684\u5730\u65b9\u52a0\u5165\u4e0b\u9762\u4ee3\u7801<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; &lt;!&#8211; #BeginLibraryItem &#8220;\/library\/pages.lbi&#8221; &#8211;&gt;&lt;!&#8211; #EndLibraryItem &#8211;&gt;<br \/>\n<br \/> &nbsp;&nbsp; \u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u5b98\u65b9\u9ed8\u8ba4\u6a21\u677f\uff0c\u90a3\u4e48\u5728<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; &lt;div class=&#8221;dashed&#8221;&gt;&lt;\/div&gt;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; \u8fd9\u884c\u4ee3\u7801\u4e0b\u9762\u52a0<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; &lt;!&#8211; #BeginLibraryItem &#8220;\/library\/pages.lbi&#8221; &#8211;&gt;&lt;!&#8211; #EndLibraryItem &#8211;&gt;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; \u6bd4\u8f83\u5408\u9002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u770b\u5230\u6709\u670b\u53cb\u5728\u8bba\u575b\u95ee\u5230\u8fc7\u6b64\u7c7b\u95ee&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199037","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199037"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199037\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}