名称: products_data($pagesize=10)
功能: 读取商品列表,默认每页显示10条数据,可以根据需要调整
模板代码示例:
<div class="row product-list"> {ephp}$_products_data = EsiteApp::app()->products_data(12);{/ephp} {if($_products_data)} <!-- PRODUCT ITEM START --> {loop $_products_data $k1 $v1} <div class="col-md-4 col-sm-6 col-xs-12"> <div class="product-item"> <div class="pi-img-wrapper"> <img src="{$v1['image'][0]}" class="img-responsive" alt="{$v1['name']}"> <div> <a href="{$v1['image'][0]}" class="btn btn-default fancybox-button">放大</a> <a href="#product-pop-up" class="btn btn-default fancybox-fast-view" onclick="apps.product_pop_up(this)" product-data='{ephp}echo json_encode($v1);{/ephp}'>详情</a> </div> </div> <h3><a href="{$v1['product_url']}">{$v1['name']}</a></h3> <div class="pi-price">${$v1['price']}</div> <a href="javascript:;" class="btn btn-default add2cart" onclick="apps['cart-add']({$v1['id']},1);">加入购物车</a> </div> </div> {/loop} <!-- PRODUCT ITEM END --> {/if} </div>
数据格式打印:
Array ( [0] => Array ( [id] => 52 [cat_id] => 15 [filename] => [name] => 女装2018春季新款双口袋衬衫8300035 [price] => 450 [weight] => 0.18 [sn] => [title] => 女装2018春季新款双口袋衬衫8300035 [keywords] => 女装 2018 春季 新款 双口袋 衬衫 绿 S M L [description] => 女装2018春季新款双口袋衬衫8300035 [content] => ... [image] => Array ( [0] => /esite_static/upload/image/day_180523/3727d5b54207e6592c725f5ffe359c29.jpg [1] => /esite_static/upload/image/day_180523/802d8feb325cdd42709ef5f1081b6088.jpg ) [edit_time] => 1527078379 [sort] => 0 [ext1] => [ext2] => [ext3] => [ext4] => [ext5] => [ext6] => [ext7] => [ext8] => [ext9] => [ext10] => [ext11] => [ext12] => [ext13] => [ext14] => [ext15] => [cat_unique_id] => 女士衬衫 [cat_name] => 女士衬衫 [category] => top_menu [product_url] => /女士衬衫/52-product.html [category_url] => /女士衬衫/p1-products.html ) )