aropixel / sylius-stock-alert-plugin
Get notifed when your product stock reaches a certain treshold
Installs: 59
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 0
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^7.3
- sylius/sylius: ^1.7
Requires (Dev)
- behat/behat: ^3.4
- behat/mink: ^1.7@dev
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.0
- friends-of-behat/variadic-extension: ^1.1
- lakion/mink-debug-extension: ^1.2.3
- phpspec/phpspec: ^6.0
- phpstan/phpstan-doctrine: ^0.11
- phpstan/phpstan-shim: ^0.11
- phpstan/phpstan-webmozart-assert: ^0.11
- phpunit/phpunit: ^8.0
- sensiolabs/security-checker: ^5.0
- sylius-labs/coding-standard: ^3.0
- symfony/browser-kit: ^3.4|^4.3
- symfony/debug-bundle: ^3.4|^4.3
- symfony/dotenv: ^4.3
- symfony/intl: ^3.4|^4.3
- symfony/web-profiler-bundle: ^3.4|^4.3
- symfony/web-server-bundle: ^4.4
This package is auto-updated.
Last update: 2024-12-19 03:24:19 UTC
README
Sylius Stock Alert Plugin
Get notifed when your product stock reaches a certain treshold
Table of contents
Presentation
Once the plugin is installed and configured, you'll be able to define in the admin a stock treshold for each product and / or taxonomy. When inventory levels fall below this threshold (wether with a new order, a stock modification in the admin or a stock treshold modification), notifications will be displayed in the admin dashboard and also sent by emails. Custom notifier can also be implemented easily.
Installation
In a sylius application :
- Install the plugin :
composer require aropixel/sylius-stock-alert-plugin
If the plugin is not registered in the config/bundles.php file, register it by adding:
Aropixel\SyliusStockAlertPlugin\AropixelSyliusStockAlertPlugin::class => ['all' => true],
- Create a aropixel_sylius_stock_alert.yaml in the config folder and import the plugin configuration:
imports:
- { resource: "@AropixelSyliusStockAlertPlugin/Resources/config/app/config.yml" }
-
Make sure the sylius mailer plugin is configured (in your config/sylius_mailer.yaml file)
-
If you need the emails stock alert, enable it and configure it in the aropixel_sylius_stock_alert.yaml (you can multiple recipients for the emails alerts):
aropixel_sylius_stock_alert:
mail_stock_notifier:
enabled: true
recipients: ['david@aropixel.com']
- use the ProductVariantTrait in your productVariant Entity
...
use Aropixel\SyliusStockAlertPlugin\Entity\ProductVariantTrait as AropixelSyliusStockAlertProductVariantTrait;
...
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product_variant")
*/
class ProductVariant extends BaseProductVariant
{
use AropixelSyliusStockAlertProductVariantTrait {
AropixelSyliusStockAlertProductVariantTrait::__construct as private __stockAlertTraitConstruct;
}
public function __construct()
{
$this->__stockAlertTraitConstruct();
parent::__construct();
}
...
}
- Use the TaxonTrait in your Taxon Entity
...
use Aropixel\SyliusStockAlertPlugin\Entity\TaxonTrait as AropixelSyliusStockAlertTaxonVariantTrait;
...
**
* @ORM\Entity
* @ORM\Table(name="sylius_taxon")
*/
class Taxon extends BaseTaxon implements Comparable
{
use AropixelSyliusStockAlertTaxonVariantTrait;
...
}
- run the migrations
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
- install the assets:
php bin/console assets:install
Usage
You can define stock treshold in the product admin ("stock" tab), but also in the taxonomies of the product. The stock treshold in the product have the highest priority: if it's defined, it will not be overrided by the stock treshold of the taxonomy. If the stock treshold of the product is not defined, the plugin will look in all the taxonomies of the product, compare them all and keep only the lowest (the most restrictive stock treshold of the taxonomies).
Everytime the stock or stock treshold changes, the plugin updates the dashboard notifications.
Everytime an order is completed, the plugin will look for all the notifiers implemented (by default only the email notifier), and send the associated notification. The Email notifier is the only one implemented by default in the plugin. If you want to implements other notifier (like SMS etc), you just need to create a class that extends the Aropixel\SyliusStockAlertPlugin\StockNotifier\StockNotifierInterface and implement the sendNotification() method. Your method will be automatically called.
License
Aropixel Blog Bundle is under the MIT License