想重写这个文件,但是没反应,程序没有走到common目录里面,是不是配置错了呢?
1.关于fecshop services,参看:http://www.fecshop.com/doc/fecshop-guide/develop/cn-1.0/guide-fecshop-service-abc.html
2.重写services参看:http://www.fecshop.com/doc/fecshop-guide/develop/cn-1.0/guide-fecshop-rewrite-func.html#3-servicesfecshop
3.category services的配置:https://github.com/fecshop/yii2_fecshop/blob/master/config/services/Category.php
4.你的配置的第一个category的子services menu,在fecshop中是存在的,参看3部分的链接,如何重写参看上面的文档
5.你的第二个子services categoryMongo是不存在的,相当于你自己加了一个子service,如果添加一个新的services,详细参看上面的文档
想重写这个CategoryMongodb类,有什么方法吗
cms article service,进行了mongodb和mysql的两种实现, 你先参看源码思考下原理吧
注意这个是cms的子service article,而不是service cms
article
cms
https://github.com/fecshop/yii2_fecshop/blob/master/config/services/Cms.php
https://github.com/fecshop/yii2_fecshop/blob/master/services/Category.php
有一个类变量:public $storage = 'CategoryMongodb';
public $storage = 'CategoryMongodb';
可以在配置中定义,值会被yii2容器注入进去。
'storage' => 'ArticleMysqldb', // ArticleMysqldb or ArticleMongodb.
原理自己读上面的article实现的代码吧。