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

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

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

asdoria/sylius-product-document-plugin

Composer 安装命令:

composer require asdoria/sylius-product-document-plugin

包简介

Asdoria Product Document

README 文档

README

Example of a product's documents customization

Asdoria Product Document Plugin

A plugin to create, group and associate documents with products

Features

  • Create type of documents
  • Easily customize which documents to display from the product configuration page
  • Document are automatically displayed on the product's store page and downloaded there

Example of a product's documents customization

Creating a document type and customizing its content in the product edit page. Example of a product's documents customization

Installation

  1. run composer require asdoria/sylius-product-document-plugin

  2. Add the bundle in config/bundles.php. You must put it ABOVE SyliusGridBundle

Asdoria\SyliusProductDocumentPlugin\AsdoriaSyliusProductDocumentPlugin::class => ['all' => true],
[...]
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
  1. Import routes in config/routes.yaml
asdoria_product_document:
    resource: "@AsdoriaSyliusProductDocumentPlugin/Resources/config/routing.yaml"
  1. Import config in config/packages/_sylius.yaml
imports:
    - { resource: "@AsdoriaSyliusProductDocumentPlugin/Resources/config/app/config.yaml"}
  1. In src/Entity/Product/Product.php. Import the following classes, traits and methods.
use Asdoria\SyliusProductDocumentPlugin\Model\Aware\ProductDocumentsAwareInterface;
use Asdoria\SyliusProductDocumentPlugin\Model\ProductDocumentInterface;
use Asdoria\SyliusProductDocumentPlugin\Traits\ProductDocumentsTrait;
use Sylius\Component\Product\Model\ProductTranslationInterface;

class Product extends BaseProduct implements  ProductDocumentsAwareInterface
{
    use ProductDocumentsTrait;

    public function __construct()
    {
        parent::__construct();
        $this->initializeProductDocumentsCollection();
    }
    
    /**
     * @param ProductDocumentInterface $productDocument
     */
    public function addProductDocument(ProductDocumentInterface $productDocument): void
    {
        if (!$this->hasProductDocument($productDocument)) {
            $productDocument->setProduct($this);
            $this->productDocuments->add($productDocument);
        }
    }

    /**
     * @param ProductDocumentInterface $productDocument
     */
    public function removeProductDocument(ProductDocumentInterface $productDocument): void
    {
        if ($this->hasProductDocument($productDocument)) {
            $productDocument->setProduct(null);
            $this->productDocuments->removeElement($productDocument);
        }
    }    
}
  1. run php bin/console do:mi:mi to update the database schema`

  2. Gaufrette is no longer used by Sylius in favour of Flysystem. If you want to use Gaufrette in your project, you need to set:

    asdoria_sylius_product_document:
        filesystem:
            adapter: gaufrette

    in your config/packages/_sylius.yaml file.

Demo

You can see the result for the user here with a cap: here.
If you want to try to create documents, go on the admin authentication page and connect with:

Login: asdoria
Password: asdoria

Then go on "Document Type" in the back office and follow usage lines below.

Note that we have developed several other open source plugins for Sylius, whose demos and documentation are listed on the following page.

Usage

  1. In the back office, under Catalog, enter Document Types. Create a type of document using a unique code.
  2. Go to a product's edit page, then click the Documents tab in the sidebar. Here you can add documents type then upload which document you wish to display for each.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固