https://github.com/opengento/magento2-document
This module aims to help merchants to manage easily their documents in Magento 2.
https://github.com/opengento/magento2-document
document-management magento magento-2 magento-extension magento-module magento2 magento2-extension magento2-extension-free magento2-module php
Last synced: about 2 months ago
JSON representation
This module aims to help merchants to manage easily their documents in Magento 2.
- Host: GitHub
- URL: https://github.com/opengento/magento2-document
- Owner: opengento
- License: mit
- Created: 2020-12-06T17:19:03.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T17:20:16.000Z (10 months ago)
- Last Synced: 2025-04-23T21:02:11.687Z (about 2 months ago)
- Topics: document-management, magento, magento-2, magento-extension, magento-module, magento2, magento2-extension, magento2-extension-free, magento2-module, php
- Language: PHP
- Homepage: https://opengento.fr
- Size: 193 KB
- Stars: 6
- Watchers: 10
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Document Module for Magento 2
[](https://packagist.org/packages/opengento/module-document)
[](./LICENSE)
[](https://packagist.org/packages/opengento/module-document/stats)
[](https://packagist.org/packages/opengento/module-document/stats)This module aims to help merchants to manage easily their documents in Magento 2.
- [Setup](#setup)
- [Composer installation](#composer-installation)
- [Setup the module](#setup-the-module)
- [Features](#features)
- [Settings](#settings)
- [Documentation](#documentation)
- [Support](#support)
- [Authors](#authors)
- [License](#license)## Setup
Magento 2 Open Source or Commerce edition is required.
### Composer installation
Run the following composer command:
```
composer require opengento/module-document
```### Setup the module
Run the following magento command:
```
bin/magento setup:upgrade
```**If you are in production mode, do not forget to recompile and redeploy the static resources.**
## Features
This module aims to help merchants to manage easily their documents in Magento 2.
Documents are sorted by types and can be manipulated with ease.- Declare new document types:
- from the back-office
- from xml config files- Create new documents:
- from the back-office
- from command line
- from a cron jobDocuments can be uploaded with a thumbnail. The default thumbnail of the document type can be used.
The thumbnail can be resized in order to optimize the performance.## Documentation
### How to declare a document type from config file
Create a new file `resource_document_types.xml` in the `etc/` folder of your module:
```xml
true
public
Certificates
cert/import/
coa/
3
CERT-*.[pP][dD][fF]
document/image/cert/thumbnail.png
```
### How to add a new import file processor
When files are import from command line or cron jobs, you cannot set manually metadata.
The code, name, and pivot field has to be filled and that is what the file import processor do.
If you need to implement your own logic on how a document should be created on the import fly, check the following code:Implement the interface `\Opengento\Document\Model\Document\ProcessorInterface`:
```php
namespace Vendor\Module\Model\Document\Processor;
use Opengento\Document\Api\Data\DocumentInterface;
use Opengento\Document\Api\Data\DocumentTypeInterface;
use Opengento\Document\Model\Document\Filesystem\File;
use Opengento\Document\Model\Document\Filesystem\Format;
use Opengento\Document\Model\Document\ProcessorInterface;
use Opengento\Document\Model\DocumentBuilder;
use function basename;
use function dirname;final class CustomProcessor implements ProcessorInterface
{
public const CODE = 'custom';/**
* @var DocumentBuilder
*/
private $documentBuilder;/**
* @var File
*/
private $fileHelper;public function __construct(
DocumentBuilder $documentBuilder,
File $fileHelper
) {
$this->documentBuilder = $documentBuilder;
$this->fileHelper = $fileHelper;
}public function execute(DocumentTypeInterface $documentType, string $filePath): DocumentInterface
{
// $filePath is the path where the source file is currently saved.
// You can change the destination path if want to.
// Edit the file path value with $this->documentBuilder->setFilePath($newDestPath).
// You can also rename the file with $this->documentBuilder->setFileName($newFileName)$destFilePath = $this->fileHelper->getFileDestPath($documentType, $filePath);
$fileName = basename($destFilePath);$this->documentBuilder->setTypeId($documentType->getId());
$this->documentBuilder->setCode(Format::formatCode($fileName));
$this->documentBuilder->setName(Format::formatName($fileName));
$this->documentBuilder->setFileName($fileName);
$this->documentBuilder->setFilePath(dirname($this->fileHelper->getRelativeFilePath($destFilePath)));return $this->documentBuilder->create();
}
}
```## Support
Raise a new [request](https://github.com/opengento/magento2-document/issues) to the issue tracker.
## Authors
- **Opengento Community** - *Lead* - [](https://twitter.com/opengento)
- **Thomas Klein** - *Maintainer* - [](https://github.com/thomas-kl1)
- **Contributors** - *Contributor* - [](https://github.com/opengento/magento2-document/graphs/contributors)## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) details.
***That's all folks!***