问题: PC端列表页面中,人气单品下面的数据从后台管理系统添加,如下图,代码中循环展示获取$hot_products 中的值,我在PC端这里打印可以获取到$hot_products的值, 当我在H5端,同样操作,并且打印$hot_products的时候,是空数组,这也就是我的疑问,这个值从那里传过来的。
本文由 gtcarry888 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。
写清楚文件路径。。。
文件路径 /addons/fecmall/fecyo/app/appfront/theme/fecyo/cms/home/index.php
1.appfront:
@fecyo\app\appfront\modules\Cms\block\home\Index.php
public function getLastData() { $this->initHead(); $hot_product_skus = Yii::$app->store->get('fecyo_info', 'hot_product_skus'); $chaoliu_s_skus_1 = Yii::$app->store->get('fecyo_info', 'chaoliu_s_skus_1'); $chaoliu_s_skus_2 = Yii::$app->store->get('fecyo_info', 'chaoliu_s_skus_2'); $chaoliu_x_skus_1 = Yii::$app->store->get('fecyo_info', 'chaoliu_x_skus_1'); $chaoliu_x_skus_2 = Yii::$app->store->get('fecyo_info', 'chaoliu_x_skus_2'); $new_product_skus = Yii::$app->store->get('fecyo_info', 'new_product_skus'); $hot_product_sku_arr = $this->getConfigArr($hot_product_skus); $chaoliu_s_sku_1_arr = $this->getConfigArr($chaoliu_s_skus_1); $chaoliu_s_sku_2_arr = $this->getConfigArr($chaoliu_s_skus_2); $chaoliu_x_sku_1_arr = $this->getConfigArr($chaoliu_x_skus_1); $chaoliu_x_sku_2_arr = $this->getConfigArr($chaoliu_x_skus_2); $new_product_sku_arr = $this->getConfigArr($new_product_skus); return [ 'hot_products' => $this->getProductBySkus($hot_product_sku_arr), 'chaoliu_s1_products' => $this->getProductBySkus($chaoliu_s_sku_1_arr), 'chaoliu_s2_products' => $this->getProductBySkus($chaoliu_s_sku_2_arr), 'chaoliu_x1_products' => $this->getProductBySkus($chaoliu_x_sku_1_arr), 'chaoliu_x2_products' => $this->getProductBySkus($chaoliu_x_sku_2_arr), 'new_products' => $this->getProductBySkus($new_product_sku_arr), ]; }
hot_products是这里返回的,这个数组里面的参数,就是view里面的变量
hot_products
2.html5部分,fecyo没有重写cms/home/index,您可以用这里的参数:https://github.com/fecshop/yii2_fecshop/blob/master/app/apphtml5/modules/Cms/block/home/Index.php#L20
或者自己重写