1.fecshop的目前的首页:
计算代码部分:https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Cms/block/home/Index.php
模板文件部分:https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/theme/base/front/cms/home/index.php
2.得到某个分类下的产品
https://github.com/fecshop/yii2_fecshop/blob/master/services/Product.php
/**
* @property $filter|array
* get artile collection by $filter
* example filter:
* [
* 'numPerPage' => 20,
* 'pageNum' => 1,
* 'orderBy' => ['_id' => SORT_DESC, 'sku' => SORT_ASC ],
* 'where' => [
* ['>','price',1],
* ['<=','price',10]
* ['sku' => 'uk10001'],
* ],
* 'asArray' => true,
* ]
* 根据传入的查询条件,得到产品的列表
*/
protected function actionColl($filter = '')
{
return $this->_product->coll($filter);
}
这个是在这里实现的:https://github.com/fecshop/yii2_fecshop/blob/master/services/product/ProductMongodb.php
你可以这样写:
$filter = [
'numPerPage' => 20,
'pageNum' => 1,
//'orderBy' => ['_id' => SORT_DESC, 'sku' => SORT_ASC ],
'where' => [
['category' => 'xxxxxxxxxxx'] // xxxxxxxx是你的mongodb中的category表 id
],
'asArray' => true,
];
$data = Yii::$service->product->coll($filter);
var_dump($data['coll']);
var_dump($data['count']);