Appearance
Linking vendors to shop users
If you want to link the vendor with the shop user within the vendor registration form, follow this steps.
- Make the ShopUser implement
VendorAwareInterfaceand useOdiseo\SyliusMarketplacePlugin\Entity\VendorAwareTrait— not the vendor plugin'sVendorTrait, which is Product-specific (it maps a required, bidirectional association back toVendor::$products, viainversedBy: 'products')
php
<?php
// src/Entity/ShopUser.php
declare(strict_types=1);
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Odiseo\SyliusMarketplacePlugin\Entity\VendorAwareTrait;
use Odiseo\SyliusVendorPlugin\Entity\VendorAwareInterface;
use Sylius\Component\Core\Model\ShopUser as BaseShopUser;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_shop_user')]
class ShopUser extends BaseShopUser implements VendorAwareInterface
{
use VendorAwareTrait;
}- Add the access control for the vendor registration route
yml
# config/packages/security.yaml
security:
access_control:
# ...
- { path: "%sylius.security.shop_regex%/vendors/register", role: ROLE_USER }- Create the database migration and apply it to your database
The vendor_id column on sylius_shop_user is not part of the plugin's shipped migrations — this feature is opt-in, so the column only exists once you enable it. Generate the migration yourself, review it, then apply it:
bash
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate