Plugin that add the possibility to receive an email notification when a product return in stock
- PHP
^8.2 - Sylius
^2.0
-
Run
composer require webgriffe/sylius-back-in-stock-notification-plugin --no-scripts. -
Add the plugin to the
config/bundles.phpfile:
Webgriffe\SyliusBackInStockNotificationPlugin\WebgriffeSyliusBackInStockNotificationPlugin::class => ['all' => true],- Import the plugin routes by creating a file in
config/routes/webgriffe_sylius_back_in_stock_notification_plugin.yamlwith the follwing content:
webgriffe_sylius_back_in_stock_notification_plugin:
resource: "@WebgriffeSyliusBackInStockNotificationPlugin/config/routing.yaml"- Import required packages config in your
config/packages/webgriffe_sylius_back_in_stock_notification_plugin.yamlfile:
imports:
- { resource: "@WebgriffeSyliusBackInStockNotificationPlugin/config/packages.yaml" }- Update the database schema and install assets:
bin/console doctrine:migrations:migrate
bin/console assets:install
bin/console sylius:theme:assets:install- Clear cache:
bin/console cache:clearThis module sends mail using a Symfony Command. Unfortunately, the command line context does not know about your VirtualHost or domain name. To fix this, the Command loads the hostname from the Subscription's channel, if nothing set it defaults to localhost. In console commands, URLs use http by default. You can change this globally with these configuration parameters:
- Edit the
config/services.ymlfile by adding the following content:
parameters:
router.request_context.scheme: https- As said early this module provides a command that check the stock of the product. You have to set the command
bin/console webgriffe:back-in-stock-notification:alertin the crontab, once a day is enough:
0 12 * * * <absolute-php-path> <absolute-path-to-sylius-dir>/bin/console webgriffe:back-in-stock-notification:alertIf you want to use our Behat defined steps you have to include our Behat class in your autoloader-dev. To achieve this adds the following line to your composer.json:
"autoload-dev": {
"psr-4": {
"Tests\\Webgriffe\\SyliusBackInStockNotificationPlugin\\": "vendor/webgriffe/sylius-back-in-stock-notification-plugin/tests/"
}
},To contribute to this plugin clone this repository, create a branch for your feature or bugfix, do your changes and then make sure al tests are passing.
composer install
(cd vendor/sylius/test-application && yarn install)
(cd vendor/sylius/test-application && yarn build)
vendor/bin/console assets:install
docker-compose up -d # only if you haven't mysql and mailhog installed locally
vendor/bin/console doctrine:database:create
vendor/bin/console doctrine:migrations:migrate -n
# Optionally load data fixtures
vendor/bin/console sylius:fixtures:load -n
symfony server:ca:install
symfony server:start -dvendor/bin/phpunitvendor/bin/behat --strict --tags="~@javascript"-
Start Headless Chrome:
google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1- Install SSL certificates (only once needed) and run test application's webserver on
127.0.0.1:8080:
symfony server:ca:install
APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon- Run Behat:
vendor/bin/behat --strict --tags="@javascript"vendor/bin/psalmvendor/bin/phpstan analyse -c phpstan.neonvendor/bin/ecs check- Using
testenvironment:
(cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load)
APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon- Using
devenvironment:
(cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load)
APP_ENV=dev symfony server:start --dir=tests/Application/public --daemonThis plugin is under the MIT license. See the complete license in the LICENSE file.
Developed by Webgriffe®.


