aminkt / yii2-shop-module
适用于购物网站的Yii2模块
v1.0.0
2017-04-21 07:20 UTC
Requires
- aminkt/yii2-ordering-module: *
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-13 23:53:29 UTC
README
注意
此模块需要aminkt/yii2-ordering-module。
使用以下链接访问订单模块
如何安装此模块
步骤1:首先将以下代码添加到项目的composer.json
文件中
"repositories": [
{
"type": "gitlab",
"url": "https://gitlab.com/aminkt/yii2-shop-module"
}
],
然后在composer.json
的require部分添加以下行
"aminkt/yii2-shop-module": "*",
之后,在您的composer中运行以下命令
Composer update aminkt/yii2-shop-module
步骤2:在您的应用程序配置的modules部分添加以下行
'ordering' => [
'class' => \aminkt\ordering\Order::className(),
'orderModelName' => models\Order::className(),
'orderItemModelName' => models\OrderItem::className(),
'customerProfileModelName' => models\Customer::className(),
'productModelName' => models\Product::className(),
],
步骤3:在您的前端应用程序配置的module部分添加以下行
'shop' => [
'class'=>\aminkt\shop\Shop::className(),
'productModel' => models\Product::className(),
'categoryModel' => models\Category::className(),
'userModel' => models\Member::className(),
'theme' => [
'pathMap' => [
\aminkt\shop\Shop::THEME_PATH =>'@frontendWeb/themes/theme_name/shop',
],
'baseUrl'=>"/themes/theme_name",
],
]
步骤4:在您的应用程序配置的components部分添加以下行
'order' => [
'class' => aminkt\ordering\components\Order::className(),
'orderModel'=> models\Order::className(),
'orderItemModel'=> models\OrderItem::className(),
],
步骤5:实现
- 在您的订单模型中实现
aminkt\ordering\interfaces\OrderInterface
- 在您的订单项模型中实现
aminkt\ordering\interfaces\OrderItemInterface
- 在您的客户用户模型中实现
aminkt\shop\interfaces\CustomerProfileInterface
- 在您的产品模型中实现
aminkt\shop\interfaces\ProductInterface
- 在您的分类模型中实现
aminkt\shop\interfaces\CategoryInterface
步骤6:将以下代码添加到您的产品模型中。
public function getCartPosition()
{
return \Yii::createObject([
'class' => ProductCartPosition::className(),
'id' => $this->id,
]);
}
步骤6:在@frontendWeb/themes/theme_name/shop
路径创建您自己的商店模板。
步骤6:享受模块带来的便利。