定制 bitexpert/sylius-product-document-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bitexpert/sylius-product-document-plugin

Composer 安装命令:

composer require bitexpert/sylius-product-document-plugin

包简介

Product document plugin for Sylius.

README 文档

README

Build Status installs on Packagist Mastodon Follow

The Product Document Plugin for Sylius allows you to attach documents (e.g. PDFs, images) to products and organize them by configurable document types.

Create document types in the admin:

Create document types in the admin

Attach documents to a product:

Attach documents to a product

Download the Documents in the storefront:

Download the Documents in the storefront:

Features

  • 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

Requirements

  • PHP 8.4 or higher
  • Sylius 2.0 or higher

Installation

  1. Install the plugin via Composer
composer require bitexpert/sylius-product-document-plugin
  1. Enable the plugin
<?php
# config/bundles.php
return [
    // ...

    BitExpert\SyliusProductDocumentPlugin\BitExpertSyliusProductDocumentPlugin::class => ['all' => true],
];
  1. Import config
# config/packages/_sylius.yaml
imports:
    # ...

    - { resource: "@BitExpertSyliusProductDocumentPlugin/config/config.yaml" }
  1. Import routing
# config/routes/bitexpert_product_document.yaml
bitexpert_product_document_admin:
    resource: "@BitExpertSyliusProductDocumentPlugin/config/routes/admin.yaml"
  1. Configure the Product entity in src/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();
    }
}
  1. Update your database schema
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate

Tests

You can run the unit tests with the following command (requires dependency installation):

./vendor/bin/phpunit

Contribution

Feel 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 start
ddev bootstrap

Credits

This plugin was inspired by the AsdoriaSyliusProductDocumentPlugin by Asdoria and has been rebuilt from scratch for Sylius 2.

License

The Sylius Product Document Plugin for Sylius is released under the MIT license.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固