2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-shop

yii2-shop it's a module for site shop backend, fork pistol88/yii2-shop

image

zpearl/yii2-shop

yii2-shop it's a module for site shop backend, fork pistol88/yii2-shop

  • Wednesday, November 2, 2016
  • by zpearl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 15 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Yii2-shop

ΠœΠΎΠ΄ΡƒΠ»ΡŒ прСдставляСт ΠΈΠ· сСбя Π±Π΅ΠΊΠ΅Π½Π΄ для Π˜Π½Ρ‚Π΅Ρ€Π½Π΅Ρ‚-ΠΌΠ°Π³Π°Π·ΠΈΠ½Π°., (*1)

yii2-shop, (*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']);?>

The Versions