odiseoteam/sylius-vendor-plugin

Vendor plugin for Sylius. Add Vendor (Brand) to your products.

Installs: 1 570

Dependents: 0

Suggesters: 0

Stars: 27

Watchers: 4

Forks: 7

Open Issues: 2

Type:sylius-plugin


README

Description

This plugin add vendors (Brands) to the Sylius products. The vendors are fully customizable by the admin.

Now supporting Sylius 1.4 with Symfony 4 + Flex structure.

Vendors admin

Demo

You can see this plugin in action in our Sylius Demo application.

Installation

  1. Run composer require odiseoteam/sylius-vendor-plugin

  2. Enable the plugin in bundles.php

<?php

return [
    // ...
    Vich\UploaderBundle\VichUploaderBundle::class => ['all' => true],
    Odiseo\SyliusVendorPlugin\OdiseoSyliusVendorPlugin::class => ['all' => true],
    // ...
];
  1. Import the plugin configurations
imports:
    - { resource: "@OdiseoSyliusVendorPlugin/Resources/config/config.yml" }
  1. Add the shop and admin routes
odiseo_sylius_vendor_admin:
    resource: "@OdiseoSyliusVendorPlugin/Resources/config/routing/admin.yml"
    prefix: /admin

odiseo_sylius_vendor_shop:
    resource: "@OdiseoSyliusVendorPlugin/Resources/config/routing/shop.yml"
    prefix: /{_locale}
    requirements:
        _locale: ^[a-z]{2}(?:_[A-Z]{2})?$
  1. Include traits
<?php
// src/Entity/Channel/Channel.php

// ...
use Odiseo\SyliusVendorPlugin\Model\VendorsAwareInterface;
use Odiseo\SyliusVendorPlugin\Model\VendorsTrait;
use Sylius\Component\Core\Model\Channel as BaseChannel;
// ...

/**
 * @MappedSuperclass
 * @Table(name="sylius_channel")
 */
class Channel extends BaseChannel implements VendorsAwareInterface
{
    use VendorsTrait;

    // ...
}
<?php
// src/Entity/Product/Product.php

// ...
use Odiseo\SyliusVendorPlugin\Model\VendorsAwareInterface;
use Odiseo\SyliusVendorPlugin\Model\VendorsTrait;
use Sylius\Component\Core\Model\Product as BaseProduct;
// ...

/**
 * @MappedSuperclass
 * @Table(name="sylius_product")
 */
class Product extends BaseProduct implements VendorsAwareInterface
{
    use VendorsTrait;

    // ...
}
  1. Add the vendor select box to the product form edit page. So, you need to run mkdir -p templates/bundles/SyliusAdminBundle/Product/Tab then cp vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/Resources/views/Product/Tab/_details.html.twig templates/bundles/SyliusAdminBundle/Product/Tab/_details.html.twig and then add the form widget
{# ... #}
{{ form_row(form.vendors) }}
{# ... #}
  1. Create logo folder: run mkdir public/media/vendor-logo -p and insert a .gitkeep file in that folder

  2. Finish the installation updating the database schema and installing assets

php bin/console doctrine:schema:update --force
php bin/console sylius:theme:assets:install

Fixtures

This plugin comes with fixtures:

Vendors

Simply add this configuration on your fixture suite:

vendor:
    options:
        vendors_per_channel: 12

Test the plugin

You can follow the instructions to test this plugins in the proper documentation page: Test the plugin.

Credits

This plugin is maintained by Odiseo. Want us to help you with this plugin or any Sylius project? Contact us on team@odiseo.com.ar.