2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-shop-backend

yii2-shop it's a module for site shop backend

image

avs123a/yii2-shop-backend

yii2-shop it's a module for site shop backend

  • Thursday, July 12, 2018
  • by avs123a
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 11 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2-shop

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

yii2-shop, (*2)

Π’ состав Π²Ρ…ΠΎΠ΄ΠΈΡ‚ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ ΡƒΠΏΡ€Π°Π²Π»ΡΡ‚ΡŒ (CRUD):, (*3)

  • ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΡΠΌΠΈ
  • ΠŸΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡΠΌΠΈ
  • Π’ΠΎΠ²Π°Ρ€Π°ΠΌΠΈ
  • Π¦Π΅Π½Π°ΠΌΠΈ
  • Π€ΠΈΠ»ΡŒΡ‚Ρ€Π°ΠΌΠΈ (опциями)
  • Π”ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΌΠΈ полями

Если Π΅ΡΡ‚ΡŒ Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎΡΡ‚ΡŒ, ΠΌΠΎΠΆΠ½ΠΎ Ρ‚Π°ΠΊΠΆΠ΅ ΠΏΠΎΠ΄Ρ‚ΡΠ½ΡƒΡ‚ΡŒ ΠΌΠΎΠΈ Π΄Ρ€ΡƒΠ³ΠΈΠ΅ ΠΌΠΎΠ΄ΡƒΠ»ΠΈ:, (*4)

Установка

Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡƒΡŽ ΡƒΡΡ‚Π°Π½Π°Π²Π»ΠΈΠ²Π°Ρ‚ΡŒ Π² common/modules/dvizh:, (*5)

git clone https://github.com/dvizh/yii2-shop.git

И ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π°Ρ‚ΡŒ Ρ‡Π΅Ρ€Π΅Π· psr-4 ΡΠ΅ΠΊΡ†ΠΈΡŽ composer.json:, (*6)

"autoload": {
    "psr-4": {
        "dvizh\\shop\\": "common/modules/dvizh/yii2-shop"
    }
}

ΠœΠΎΠ΄ΡƒΠ»ΡŒ зависит ΠΎΡ‚ ΠΌΠ½ΠΎΠ³ΠΈΡ… Π΄Ρ€ΡƒΠ³ΠΈΡ… ΠΏΠ°ΠΊΠ΅Ρ‚ΠΎΠ², скопируйтС ΠΈΡ… ΠΈΠ· ΠΌΠΎΠ΅Π³ΠΎ Π² свой composer.json Π² ΡΠ΅ΠΊΡ†ΠΈΡŽ require. ПослС этого Π½Π΅ Π·Π°Π±ΡƒΠ΄ΡŒΡ‚Π΅ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ composer update ΠΈ ΠΌΠΈΠ³Ρ€Π°Ρ†ΠΈΠΈ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ модуля., (*7)

Если Ρ…ΠΎΡ‚ΠΈΡ‚Π΅ ΡƒΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ Π² ΠΏΠ°ΠΏΠΊΡƒ vendor Ρ‡Π΅Ρ€Π΅Π· composer ΠΈ Π½ΠΈΡ‡Π΅Π³ΠΎ Π½Π΅ ΠΌΠ΅Π½ΡΡ‚ΡŒ ΠΏΠΎΡ‚ΠΎΠΌ, устанавливайтС стандартно: 'php composer require dvizh/yii2-shop "@dev"' Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ строкС., (*8)

ΠœΠΈΠ³Ρ€Π°Ρ†ΠΈΡ:, (*9)

php yii migrate --migrationPath=vendor/dvizh/yii2-shop/src/migrations

Настройка

Π’ ΠΊΠΎΠ½Ρ„ΠΈΠ³ (скорСС всСго, bootstrap.php) Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ:, (*10)

Yii::setAlias('@storageUrl','/frontend/web/images');

Π’ ΡΠ΅ΠΊΡ†ΠΈΡŽ modules ΠΊΠΎΠ½Ρ„ΠΈΠ³Π° Π΄ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ:, (*11)

    'modules' => [
        //..
        'shop' => [
            'class' => 'dvizh\shop\Module',
            'adminRoles' => ['administrator', 'superadmin', 'admin'],
            'defaultPriceTypeId' => 1, //Π¦Π΅Π½Π° ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ
        ],
        'filter' => [
            'class' => 'dvizh\filter\Module',
            'adminRoles' => ['administrator'],
            'relationFieldName' => 'category_id',
            'relationFieldValues' =>
                function() {
                    return \dvizh\shop\models\Category::buildTextTree();
                },
        ],
        'field' => [
            'class' => 'dvizh\field\Module',
            'relationModels' => [
                'dvizh\shop\models\Product' => 'ΠŸΡ€ΠΎΠ΄ΡƒΠΊΡ‚Ρ‹',
                'dvizh\shop\models\Category' => 'ΠšΠ°Ρ‚Π΅Π³ΠΎΡ€ΠΈΠΈ',
                'dvizh\shop\models\Producer' => 'ΠŸΡ€ΠΎΠΈΠ·Π²ΠΎΠ΄ΠΈΡ‚Π΅Π»ΠΈ',
            ],
            'adminRoles' => ['administrator'],
        ],
        'relations' => [
            'class' => 'dvizh\relations\Module',
            'fields' => ['code'],
        ],
        'gallery' => [
            'class' => 'dvizh\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',
        ],
        //..
    ]

Π’ ΡΠ΅ΠΊΡ†ΠΈΡŽ components:, (*12)

    '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 - Π΄ΠΎΠΏ. поля

Π’ΠΈΠ΄ΠΆΠ΅Ρ‚Ρ‹

  • dvizh\shop\widgets\ShowPrice - пСрСдаСтся 'model', Π²Ρ‹Π²ΠΎΠ΄ΠΈΡ‚ Ρ†Π΅Π½Ρƒ. Бвязан с dvizh\cart\widgets\ChangeOptions Ρ‡Π΅Ρ€Π΅Π· jQuery Ρ‚Ρ€ΠΈΠ³Π³Π΅Ρ€ ΠΈ ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΡΡ‚ΡŒ, какая модификация Π²Ρ‹Π±Ρ€Π°Π½Π° ΠΈ динамичСски ΠΌΠ΅Π½ΡΡ‚ΡŒ Ρ†Π΅Π½Ρƒ.

ΠŸΡ€ΠΈΠΌΠ΅Ρ€ ΠΊΠ°Ρ€Ρ‚ΠΎΡ‡ΠΊΠΈ Ρ‚ΠΎΠ²Π°Ρ€Π° со всСми Π²ΠΈΠ΄ΠΆΠ΅Ρ‚Π°ΠΌΠΈ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° ΠΈ ΠΊΠΎΡ€Π·ΠΈΠ½Ρ‹, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ Ρ€Π°Π±ΠΎΡ‚Π°ΡŽΡ‚ сообща ΠΈ динамичСски ΠΌΠ΅Π½ΡΡŽΡ‚ Π΄Π°Π½Π½Ρ‹Π΅ Π΄Ρ€ΡƒΠ³-Π΄Ρ€ΡƒΠ³Π°., (*13)




=$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