| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Add brand to your products in Sylius.
composer require loevgaard/sylius-brand-pluginEnable 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],
// ...
];# config/routes/loevgaard_sylius_brand.yaml
loevgaard_sylius_brand:
resource: "@LoevgaardSyliusBrandPlugin/config/routes.yaml"Extend your Product entity to implement BrandAwareInterface:
<?php
// src/Entity/Product/Product.php
declare(strict_types=1);
namespace App\Entity\Product;
use Doctrine\ORM\Mapping as ORM;
use Loevgaard\SyliusBrandPlugin\Model\BrandAwareInterface;
use Loevgaard\SyliusBrandPlugin\Model\BrandAwareTrait;
use Sylius\Component\Core\Model\Product as BaseProduct;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_product')]
class Product extends BaseProduct implements BrandAwareInterface
{
use BrandAwareTrait;
}The BrandAwareTrait already includes the Doctrine ORM mapping attributes, so you don't need to add any additional mapping configuration.
# config/packages/sylius_product.yaml
sylius_product:
resources:
product:
classes:
model: App\Entity\Product\ProductThe above configuration is most likely already done in your application.
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate# config/packages/loevgaard_sylius_brand.yaml
imports:
- { resource: "@LoevgaardSyliusBrandPlugin/config/grids/sylius_admin_product.yaml" }Include predefined brand fixtures to play with on your dev environment:
# config/packages/loevgaard_sylius_brand.yaml
imports:
- { resource: "@LoevgaardSyliusBrandPlugin/config/fixtures.yaml" }Or write your own:
# config/packages/my_fixtures.yaml
sylius_fixtures:
suites:
my_brand_fixtures:
fixtures:
loevgaard_sylius_brand_plugin_brand:
options:
custom:
my_brand:
name: 'My brand'
code: 'my-brand'
images:
- type: logo
path: images/my-brand/logo.jpg
products:
- product_code_1
- product_code_2Load your fixtures:
php bin/console sylius:fixture:load my_brand_fixturesThe plugin uses Sylius Twig Hooks for customization. Available hook points:
Product form:
Brand form:
Currently supported languages:
| Back | FazBrowse Home | New Git URL |