loevgaard / SyliusBrandPlugin

A Sylius plugin to enable the association of brands to your products
MIT License
30 stars 29 forks source link
php php7 sylius sylius-plugin symfony

Sylius Brand Plugin

Latest Version on Packagist Software License Build Status Quality Score

If you want to add a brand to your products this is the plugin to use. Use cases:

Screenshots

CLICK TO SEE Menu: ![Screenshot showing admin menu](docs/images/admin-menu-with-brand.png) Brand admin pages: ![Screenshot showing brand admin index page](docs/images/admin-brand-index.png) ![Screenshot showing brand admin update page](docs/images/admin-brand-update.png) ![Screenshot showing brand admin media tab at update page](docs/images/admin-brand-update-tab-media.png) Products admin pages: ![Screenshot showing product admin index page with brand filter](docs/images/admin-product-index-filter-with-brand.png) ![Screenshot showing product admin index page with brand column](docs/images/admin-product-index-brand-column.png) ![Screenshot showing brand tab at product admin update page](docs/images/admin-product-update-tab-brand.png)

Installation

Step 1: Download the plugin

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require loevgaard/sylius-brand-plugin

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the plugin

Then, enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php file of your project before (!) SyliusGridBundle:

<?php

# config/bundles.php

return [
    // ...
    Loevgaard\SyliusBrandPlugin\LoevgaardSyliusBrandPlugin::class => ['all' => true],
    Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
    // ...
];

Step 3: Configure the plugin

# config/packages/loevgaard_sylius_brand.yaml

imports:
    # ...
    - { resource: "@LoevgaardSyliusBrandPlugin/Resources/config/app/config.yaml" }

    # If you want to see Brand column at admin products list - uncomment next line
    # - { resource: "@LoevgaardSyliusBrandPlugin/Resources/config/grids/sylius_admin_product.yaml" }
# config/routes/loevgaard_sylius_brand.yaml

loevgaard_sylius_brand:
    resource: "@LoevgaardSyliusBrandPlugin/Resources/config/routing.yaml"

Step 4: Extend services and entities

Extend Product

Extend ProductRepository

<?php
# src/Doctrine/ORM/ProductRepository.php

declare(strict_types=1);

namespace App\Doctrine\ORM;

use Loevgaard\SyliusBrandPlugin\Doctrine\ORM\ProductRepositoryInterface as LoevgaardSyliusBrandPluginProductRepositoryInterface;
use Loevgaard\SyliusBrandPlugin\Doctrine\ORM\ProductRepositoryTrait as LoevgaardSyliusBrandPluginProductRepositoryTrait;
use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;

class ProductRepository extends BaseProductRepository implements LoevgaardSyliusBrandPluginProductRepositoryInterface
{
    use LoevgaardSyliusBrandPluginProductRepositoryTrait;

    // ...
}

Configure

config/services.yaml

sylius_product:
    resources:
        product:
            classes:
                model: App\Model\Product # Or App\Entity\Product
                repository: App\Doctrine\ORM\ProductRepository

Step 5: Update your database schema

$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate

Fixtures

Installation and usage for plugin development

To run test application to play with just type composer try.

Sonata blocks available

Events available

Testing

Play with API

Contribute

Please, run composer all to run all checks and tests before committing.

Contribute by translating

We use the same service as Sylius for translating, namely Crowdin. You can help out by translating this project into your mother tongue ;)

Thanks!