Yii2-shop
ΠΠΎΠ΄ΡΠ»Ρ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΠΈΠ· ΡΠ΅Π±Ρ Π±Π΅ΠΊΠ΅Π½Π΄ Π΄Π»Ρ ΠΠ½ΡΠ΅ΡΠ½Π΅Ρ-ΠΌΠ°Π³Π°Π·ΠΈΠ½Π°., (*1)
, (*2)
Π ΡΠΎΡΡΠ°Π² Π²Ρ
ΠΎΠ΄ΠΈΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΡΠΏΡΠ°Π²Π»ΡΡΡ (CRUD):, (*3)
- ΠΠ°ΡΠ΅Π³ΠΎΡΠΈΡΠΌΠΈ
- ΠΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΡΠΌΠΈ
- Π’ΠΎΠ²Π°ΡΠ°ΠΌΠΈ
- Π¦Π΅Π½Π°ΠΌΠΈ
- Π€ΠΈΠ»ΡΡΡΠ°ΠΌΠΈ (ΠΎΠΏΡΠΈΡΠΌΠΈ)
- ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠΌΠΈ ΠΏΠΎΠ»ΡΠΌΠΈ
ΠΡΠ»ΠΈ Π΅ΡΡΡ Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎΡΡΡ, ΠΌΠΎΠΆΠ½ΠΎ ΡΠ°ΠΊΠΆΠ΅ ΠΏΠΎΠ΄ΡΡΠ½ΡΡΡ ΠΌΠΎΠΈ Π΄ΡΡΠ³ΠΈΠ΅ ΠΌΠΎΠ΄ΡΠ»ΠΈ:, (*4)
Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΡ ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΡΡ Π² common/modules/pistol88:, (*5)
git clone https://github.com/pistol88/yii2-shop.git
Π ΠΏΠΎΠ΄ΠΊΠ»ΡΡΠ°ΡΡ ΡΠ΅ΡΠ΅Π· psr-4 ΡΠ΅ΠΊΡΠΈΡ composer.json:, (*6)
"autoload": {
"psr-4": {
"pistol88\\shop\\": "common/modules/pistol88/yii2-shop"
}
}
ΠΠΎΠ΄ΡΠ»Ρ Π·Π°Π²ΠΈΡΠΈΡ ΠΎΡ ΠΌΠ½ΠΎΠ³ΠΈΡ
Π΄ΡΡΠ³ΠΈΡ
ΠΏΠ°ΠΊΠ΅ΡΠΎΠ², ΡΠΊΠΎΠΏΠΈΡΡΠΉΡΠ΅ ΠΈΡ
ΠΈΠ· ΠΌΠΎΠ΅Π³ΠΎ Π² ΡΠ²ΠΎΠΉ composer.json Π² ΡΠ΅ΠΊΡΠΈΡ require. ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ Π½Π΅ Π·Π°Π±ΡΠ΄ΡΡΠ΅ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ composer update ΠΈ ΠΌΠΈΠ³ΡΠ°ΡΠΈΠΈ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΠΌΠΎΠ΄ΡΠ»Ρ., (*7)
ΠΡΠ»ΠΈ Ρ
ΠΎΡΠΈΡΠ΅ ΡΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Π² ΠΏΠ°ΠΏΠΊΡ vendor ΡΠ΅ΡΠ΅Π· composer ΠΈ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ ΠΌΠ΅Π½ΡΡΡ ΠΏΠΎΡΠΎΠΌ, ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΠΉΡΠ΅ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΠΎ: 'php composer require pistol88/yii2-shop' ΠΈ 'php composer update' Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅., (*8)
ΠΠΈΠ³ΡΠ°ΡΠΈΡ:, (*9)
php yii migrate --migrationPath=vendor/pistol88/yii2-shop/migrations
ΠΠ°ΡΡΡΠΎΠΉΠΊΠ°
Π ΠΊΠΎΠ½ΡΠΈΠ³ (ΡΠΊΠΎΡΠ΅Π΅ Π²ΡΠ΅Π³ΠΎ, bootstrap.php) Π΄ΠΎΠ±Π°Π²ΠΈΡΡ:, (*10)
Yii::setAlias('@storageUrl','/frontend/web/images');
Π ΡΠ΅ΠΊΡΠΈΡ modules ΠΊΠΎΠ½ΡΠΈΠ³Π° Π΄ΠΎΠ±Π°Π²ΠΈΡΡ:, (*11)
'modules' => [
//..
'shop' => [
'class' => 'zpearl\shop\Module',
'adminRoles' => ['administrator'],
],
'filter' => [
'class' => 'pistol88\filter\Module',
'adminRoles' => ['administrator'],
'relationModel' => 'zpearl\shop\models\Product',
'relationFieldName' => 'category_id',
'relationFieldValues' =>
function() {
return \zpearl\shop\models\buldTextTree();
},
],
'field' => [
'class' => 'pistol88\field\Module',
'relationModels' => [
'zpearl\shop\models\Product' => 'ΠΡΠΎΠ΄ΡΠΊΡΡ',
'zpearl\shop\models\Category' => 'ΠΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ',
'zpearl\shop\models\Producer' => 'ΠΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΠΈ',
],
'adminRoles' => ['administrator'],
],
'relations' => [
'class' => 'pistol88\relations\Module',
'fields' => ['code'],
],
'gallery' => [
'class' => 'pistol88\gallery\Module',
'imagesStorePath' => dirname(dirname(__DIR__)).'/storage/web/images/store',
'imagesCachePath' => dirname(dirname(__DIR__)).'/storage/web/images/cache',
'graphicsLibrary' => 'GD',
'placeHolderPath' => dirname(dirname(__DIR__)).'/storage/web/images/placeHolder.png',
],
//..
]
Π shop ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅ΡΠ΅Π΄Π°ΡΡ modelMap, Π³Π΄Π΅ ΡΠΊΠ°Π·Π°ΡΡ Π½ΡΠΆΠ½ΡΠ΅ Π²Π°ΠΌ ΠΌΠΎΠ΄Π΅Π»ΠΈ. Π’Π°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΡΠΊΠ°Π·Π°ΡΡ ΡΡΠ°Π½Π΄Π°ΡΡΠ½ΡΠ΅ yiiΡΠ½ΡΠ΅ controllerMap, viewPath, ΡΡΠΎΠ±Ρ ΠΏΠΎΠ΄ΠΌΠ΅Π½ΠΈΡΡ ΠΊΠΎΠ½ΡΡΠΎΠ»Π»Π΅ΡΡ ΠΈ Π²ΡΡΡ
ΠΈ ΡΠ²ΠΎΠΈΠΌΠΈ Π² ΠΏΡΠΎΡΠ΅ΡΡΠ΅ ΡΠ°Π·Π²ΠΈΡΠΈΡ Π²Π°ΡΠ΅Π³ΠΎ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π°., (*12)
Π ΡΠ΅ΠΊΡΠΈΡ components:, (*13)
'components' => [
//..
'fileStorage' => [
'class' => '\trntv\filekit\Storage',
'baseUrl' => '@storageUrl/source',
'filesystem'=> function() {
$adapter = new \League\Flysystem\Adapter\Local(dirname(dirname(__DIR__)).'/frontend/web/images/source');
return new League\Flysystem\Filesystem($adapter);
},
],
//..
]
ΠΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅
- ?r=shop/product - ΠΏΡΠΎΠ΄ΡΠΊΡΡ
- ?r=shop/category - ΠΊΠ°ΡΠ΅Π³ΠΎΡΠΈΠΈ
- ?r=shop/producer - ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡΠ΅Π»ΠΈ
- ?r=filter/filter - ΡΠΈΠ»ΡΡΡΡ (ΠΎΠΏΡΠΈΠΈ)
- ?r=field/field - Π΄ΠΎΠΏ. ΠΏΠΎΠ»Ρ
ΠΠΈΠ΄ΠΆΠ΅ΡΡ
- zpearl\shop\widgets\ShowPrice - ΠΏΠ΅ΡΠ΅Π΄Π°Π΅ΡΡΡ 'model', Π²ΡΠ²ΠΎΠ΄ΠΈΡ ΡΠ΅Π½Ρ. Π‘Π²ΡΠ·Π°Π½ Ρ pistol88\cart\widgets\ChangeOptions ΡΠ΅ΡΠ΅Π· jQuery ΡΡΠΈΠ³Π³Π΅Ρ ΠΈ ΠΌΠΎΠΆΠ΅Ρ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΡΡ, ΠΊΠ°ΠΊΠ°Ρ ΠΌΠΎΠ΄ΠΈΡΠΈΠΊΠ°ΡΠΈΡ Π²ΡΠ±ΡΠ°Π½Π° ΠΈ Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈ ΠΌΠ΅Π½ΡΡΡ ΡΠ΅Π½Ρ.
ΠΡΠΈΠΌΠ΅Ρ ΠΊΠ°ΡΡΠΎΡΠΊΠΈ ΡΠΎΠ²Π°ΡΠ° ΡΠΎ Π²ΡΠ΅ΠΌΠΈ Π²ΠΈΠ΄ΠΆΠ΅ΡΠ°ΠΌΠΈ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° ΠΈ ΠΊΠΎΡΠ·ΠΈΠ½Ρ, ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠ°Π±ΠΎΡΠ°ΡΡ ΡΠΎΠΎΠ±ΡΠ° ΠΈ Π΄ΠΈΠ½Π°ΠΌΠΈΡΠ΅ΡΠΊΠΈ ΠΌΠ΅Π½ΡΡΡ Π΄Π°Π½Π½ΡΠ΅ Π΄ΡΡΠ³-Π΄ΡΡΠ³Π°., (*14)
=$product->name;?>
Shop
ShowPrice
=ShowPrice::widget(['model' => $product]);?>
Cart
ChangeCount
=ChangeCount::widget(['model' => $product]);?>
ChangeOptions
=ChangeOptions::widget(['model' => $product]);?>
BuyButton
=BuyButton::widget(['model' => $product]);?>
TruncateButton
=TruncateButton::widget();?>
CartInformer
=CartInformer::widget();?>
ElementsList
=ElementsList::widget(['type' => 'dropdown']);?>