https://github.com/asdoria/asdoriasyliusproductdocumentplugin
Manage The Product Documents
https://github.com/asdoria/asdoriasyliusproductdocumentplugin
document ecommerce php product-file sylius sylius-plugin
Last synced: about 1 year ago
JSON representation
Manage The Product Documents
- Host: GitHub
- URL: https://github.com/asdoria/asdoriasyliusproductdocumentplugin
- Owner: asdoria
- Created: 2022-02-15T13:40:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-14T10:55:26.000Z (over 3 years ago)
- Last Synced: 2025-04-12T10:09:40.763Z (about 1 year ago)
- Topics: document, ecommerce, php, product-file, sylius, sylius-plugin
- Language: PHP
- Homepage:
- Size: 1.81 MB
- Stars: 9
- Watchers: 0
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

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

Creating a document type and customizing its content in the product edit page.

## Installation
1. run `composer require asdoria/sylius-product-document-plugin`
2. Add the bundle in `config/bundles.php`. You must put it ABOVE `SyliusGridBundle`
```PHP
Asdoria\SyliusProductDocumentPlugin\AsdoriaSyliusProductDocumentPlugin::class => ['all' => true],
[...]
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
```
3. Import routes in `config/routes.yaml`
```yaml
asdoria_product_document:
resource: "@AsdoriaSyliusProductDocumentPlugin/Resources/config/routing.yaml"
```
4. Import config in `config/packages/_sylius.yaml`
```yaml
imports:
- { resource: "@AsdoriaSyliusProductDocumentPlugin/Resources/config/app/config.yaml"}
```
5. In `src/Entity/Product/Product.php`. Import the following classes, traits and methods.
```PHP
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);
}
}
}
```
6. run `php bin/console do:mi:mi` to update the database schema`
7. Gaufrette is no longer used by Sylius in favour of Flysystem. If you want to use Gaufrette in your project, you need
to set:
```yaml
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](https://demo-sylius.asdoria.fr/en_US/products/knitted-wool-blend-green-cap).
If you want to try to create documents, go on [the admin authentication page](https://demo-sylius.asdoria.fr/admin/) and connect with:
> **Login:** asdoria
> **Password:** asdoria
>
Then go on ["Document Type" in the back office](https://demo-sylius.asdoria.fr/admin/document-types/) 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](https://asdoria.github.io/).
## 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.