The Product Document Plugin for Sylius allows you to attach documents (e.g. PDFs, images) to products and organize them by configurable document types.
- Manage document types with translatable names and sortable positions
- Attach multiple documents to a product, organized by document type
- Download documents in the storefront and in the admin
- Control document visibility: public for all visitors or restricted to logged-in customers
- PHP 8.4 or higher
- Sylius 2.0 or higher
- Install the plugin via Composer
composer require bitexpert/sylius-product-document-plugin- Enable the plugin
<?php
# config/bundles.php
return [
// ...
BitExpert\SyliusProductDocumentPlugin\BitExpertSyliusProductDocumentPlugin::class => ['all' => true],
];- Import config
# config/packages/_sylius.yaml
imports:
# ...
- { resource: "@BitExpertSyliusProductDocumentPlugin/config/config.yaml" }- Import routing
# config/routes/bitexpert_product_document.yaml
bitexpert_product_document_admin:
resource: "@BitExpertSyliusProductDocumentPlugin/config/routes/admin.yaml"
bitexpert_product_document_shop:
resource: "@BitExpertSyliusProductDocumentPlugin/config/routes/shop.yaml"- Configure the
Productentity insrc/Entity/Product/Product.php
Add the BitExpert\SyliusProductDocumentPlugin\Model\HasProductDocumentsInterface interface and the BitExpert\SyliusProductDocumentPlugin\Entity\Trait\HasProductDocumentsTrait trait to the entity.
<?php
declare(strict_types=1);
namespace App\Entity\Product;
use BitExpert\SyliusProductDocumentPlugin\Entity\Trait\HasProductDocumentsTrait;
use BitExpert\SyliusProductDocumentPlugin\Model\HasProductDocumentsInterface;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Product as BaseProduct;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_product')]
class Product extends BaseProduct implements HasProductDocumentsInterface
{
use HasProductDocumentsTrait;
public function __construct()
{
parent::__construct();
$this->initializeProductDocumentsCollection();
}
}- Update your database schema
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrateYou can run the unit tests with the following command (requires dependency installation):
./vendor/bin/phpunitFeel free to contribute to this module by reporting issues or creating pull requests for improvements.
To run the Test Application included in the repo, refer to the Sylius Test Application docs. If you are using DDEV you can run the following commands to bootstrap the Test Application in Docker:
ddev startddev bootstrapThis plugin was inspired by the AsdoriaSyliusProductDocumentPlugin by Asdoria and has been rebuilt from scratch for Sylius 2.
The Sylius Product Document Plugin for Sylius is released under the MIT license.


