black-lamp/blcms-shop

There is no license information available for the latest version (v0.5.21) of this package.

Shop module for Black-Lamp CMS

Installs: 613

Dependents: 6

Suggesters: 0

Security: 0

Stars: 1

Watchers: 5

Forks: 0

Open Issues: 1

Type:yii2-extension

v0.5.21 2017-11-29 16:31 UTC

README

Applying migrations: !Important: this migrations must be applied after Dectrium-User module migrations.

- php yii migrate --migrationPath=@yii/rbac/migrations
- php yii migrate --migrationPath=@vendor/black-lamp/blcms-shop/migrations

For cart module:

- php yii migrate --migrationPath=@vendor/black-lamp/blcms-cart/migrations

Configuration for Imagable module:

        'shop_imagable' => [
            'class' => bl\imagable\Imagable::className(),
            'imageClass' => \bl\imagable\instances\CreateImageImagine::className(),
            'nameClass' => bl\imagable\name\CRC32Name::className(),
            'imagesPath' => '@frontend/web/images',
            'categories' => [
                'origin' => false,
                'category' => [
                    'shop-product' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 500,
                                'height' => 500,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                    'shop-vendors' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 320,
                                'height' => 240,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                    'delivery' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 500,
                                'height' => 500,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                    'shop-category/cover' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 500,
                                'height' => 500,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                    'shop-category/thumbnail' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 500,
                                'height' => 500,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                    'shop-category/menu_item' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 500,
                                'height' => 500,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                    'payment' => [
                        'origin' => false,
                        'size' => [
                            'big' => [
                                'width' => 1500,
                                'height' => 500
                            ],
                            'thumb' => [
                                'width' => 500,
                                'height' => 500,
                            ],
                            'small' => [
                                'width' => 150,
                                'height' => 150
                            ]
                        ]
                    ],
                ]
            ]
        ],

Add module to your backend config

    'bootstrap' => [
        //'bl\cms\shop\backend\components\events\PartnersBootstrap',
        'bl\cms\shop\backend\components\events\ShopLogBootstrap',
        'bl\cms\cart\backend\components\events\CartBootstrap',
    ],
    'modules' => [
        'shop' => [
            'class' => 'bl\cms\shop\backend\Module',
            'enableCurrencyConversion' => true
        ]
    ],
    'components' => [
        'urlManagerFrontend' => [
            'class' => bl\multilang\MultiLangUrlManager::className(),
            'baseUrl' => '/',
            'showScriptName' => false,
            'enablePrettyUrl' => true,
            'enableDefaultLanguageUrlCode' => false,
            'rules' => [
                [
                    'class' => bl\articles\UrlRule::className()
                ],
                [
                    'class' => bl\cms\shop\UrlRule::className(),
                    'prefix' => 'shop'
                ],
            ]
        ]
    ]

Add module to your frontend config

    'modules' => [
    	...
        'shop' => [
                    'class' => bl\cms\shop\frontend\Module::className(),
                    'enableCurrencyConversion' => true,
                    'partnerManagerEmail' => $params['partnerManagerEmail'],
                    'senderEmail' => $params['senderEmail'],
                    'showChildCategoriesProducts' => false
                ],
        ...
    ],
    
    'components' => [
        ...
        'urlManager' => [
            ...
            'rules' => [
                ...
                [
                    'class' => bl\cms\shop\UrlRule::className(),
                    'prefix' => 'shop'
                ]
            ],
            ...
        ],
        'partnerMailer' => [
                    'class' => yii\swiftmailer\Mailer::className(),
                    'useFileTransport' => false,
                    'messageConfig' => [
                        'charset' => 'UTF-8',
                    ],
                    'viewPath' => '@vendor/black-lamp/blcms-shop/frontend/views/partner-request/mail',
                    'htmlLayout' => '@vendor/black-lamp/blcms-shop/frontend/views/partner-request/mail/layout',
                    'transport' => [
                        'class' => 'Swift_SmtpTransport',
                        'username' => 'info@mail.com',
                        'password' => '55555555',
                        'host' => 'pop.mail.com',
                        'port' => '587',
                    ],
                ],
        ...
    ]

    'bootstrap' => [
        'bl\cms\shop\frontend\components\events\PartnersBootstrap',
        'bl\cms\cart\frontend\components\events\UserRegistrationBootstrap'
    ],

If you need some console import scripts:

    'modules' => [
        'shop' => [
            'class' => \bl\cms\shop\console\Module::className(),
            'importActions' => [
                'basic' => [
                    'class' => bl\cms\shop\console\actions\import\BasicAction::className()
                ]
            ]
        ]
    ],

REQUIRES

  • PHP-version: 7.0 or later
  • PHP-extensions: file-info, imagick, intl

Roles and its permissions:

attributeManager

  • addAttributeValue
  • deleteAttribute
  • saveAttribute
  • viewAttributeList

countryManager

  • saveCountry
  • viewCountryList
  • deleteCountry

currencyManager

  • updateCurrency
  • viewCurrencyList
  • deleteCurrency

deliveryMethodManager

  • saveDeliveryMethod
  • viewDeliveryMethodList
  • deleteDeliveryMethod

filterManager

  • deleteFilter
  • saveFilter
  • viewFilterList

orderManager

  • deleteOrder
  • deleteOrderProduct
  • viewOrder
  • viewOrderList

orderStatusManager

  • saveOrderStatus
  • viewOrderStatusList
  • deleteOrderStatus

productAvailabilityManager

  • saveProductAvailability
  • viewProductAvailabilityList
  • deleteProductAvailability

productManager

  • createProduct
  • createProductWithoutModeration
  • deleteOwnProduct
  • deleteProduct
  • updateOwnProduct
  • updateProduct
  • viewCompleteProductList
  • viewProductList

productPartner

  • accessAdminPanel
  • createProduct
  • createProductWithoutModeration
  • deleteOwnProduct
  • deleteProduct
  • updateOwnProduct
  • updateProduct
  • viewCompleteProductList
  • viewProductList

shopCategoryManager

  • saveShopCategory
  • viewShopCategoryList

vendorManager

  • saveVendor
  • viewVendorList
  • deleteVendor

shopAdministrator extends permissions from all managers.

WIDGETS

Recommended products

Example:

<?= \bl\cms\shop\widgets\RecommendedProducts::widget([
    'id' => $product->id,
]); ?>

Also you may use bl\cms\shop\widgets\assets\RecommendedProductsAsset in your view.

Filtration widget

To use the widget, you must have set up relations in the models. For example in model Product:

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getProductCountry()
    {
        return $this->hasOne(ProductCountry::className(), ['id' => 'country_id']);
    }

LOGGING

Your application can record how many people watched a particular product. To enable logging, you must add the following settings in the frontend configuration file:

public $log = [
        'enabled' => true,
        'maxProducts' => 10 // Max number of viewed products by one user.
    ];

In it, you specify the number of products, which is stored in the table shop_product_views for one user. This value can be 'all', ie infinitely.

If the 'maxProducts' property value is "all", the "views" of Product object increases by one for a registered user once. Otherwise it will increase by one each time when registered user views product.

TRANSLATIONS

The module has translations on several languages. If there is not your language or if you would like change its on your own, you can configure it in backend or frontend configuration file:

'i18n' => [
            'translations' => [
                'shop' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@backend/messages',
                    'sourceLanguage' => 'en-us',
                ]
            ],
        ],

REPORTS

  • "Class 'Imagick' not found"

If you use OpenServer with PHP 7, you must install Imagick extension like here http://open-server.ru/forum/viewtopic.php?f=4&t=2897&hilit=imagick

Products displaying

You can select one of two modes: showing products of current category and its children or only current category. Use property $showChildCategoriesProducts in frontend Module class configuration. migration:

Logging This configuration is for Shop module and Cart module.

For enable logging add log component to your common configuration file:

'components' => [
        'log' => [
            'targets' => [
                [
                    'logTable' => 'shop_log',
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['info'],
                    'categories' => [
                        'afterCreateProduct', 'afterDeleteProduct', 'afterEditProduct',
                        'afterCreateCategory', 'afterEditCategory', 'afterDeleteCategory',
                    ],
                ],
                [
                    'logTable' => 'cart_log',
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['info'],
                    'categories' => [
                        'afterChangeOrderStatus'
                    ],
                ],
                [
                    'logTable' => 'user_log',
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['info'],
                    'categories' => [
                        'afterRegister', 'afterConfirm'
                    ],
                ],
            ],
        ],

Then apply migration, but only after you will configure your app. The migration will create tables for log targets, which are listed in configuration.

php yii migrate --migrationPath=@yii/log/migrations/

In backend and frontend configuration of your module add

'enableLog' => true,

Vendor list

  • /shop/vendor

Partner requests email Create new templates 'partner-request-manager' and 'partner-request-partner': /admin/email-templates/default/list

You can use next variables: '{contact_person}', '{company_name}', '{website}', '{message}', '{name}', '{surname}', '{patronymic}', '{info}'

Also create template 'partner-request-accept' without variables.

Information about new product by product partner to manager - template 'new-product-to-manager'. You can use next variables: {productId}, {title}, {ownerId}, {ownerEmail}, {owner}, {link} For sending information abount new product to partner which created this product, add template 'new-product-to-partner' with variables {productId}, {title}, {ownerId}, {ownerEmail}, {owner}, {link}.

If product is moderated and status is 'accept' the mail 'accept-product-to-owner' will be sent. You may use variables: {title}, {ownerEmail}, {owner}, {link}