arobases/sylius-back-in-stock-notification-plugin

当产品库存恢复时,及时通知客户和访客

1.1.3 2023-01-23 09:05 UTC

This package is not auto-updated.

Last update: 2024-09-17 15:07:52 UTC


README

库存恢复通知插件

添加产品库存恢复时接收电子邮件通知的可能性

Build Status

功能

订阅以获取产品库存恢复时的通知

Subscription process for configurable product

Subscription for simple product

在您的账户相应部分查看您的订阅

See the apposite section in the my account

在相应的管理员部分查看您的客户订阅

See the apposite section in the admin account

要求

  • PHP ^7.3
  • Sylius ^1.8

安装

  1. 运行 composer require webgriffe/sylius-back-in-stock-notification-plugin.

  2. 将插件添加到 config/bundles.php 文件中

    Webgriffe\SyliusBackInStockNotificationPlugin\WebgriffeSyliusBackInStockNotificationPlugin::class => ['all' => true],
  3. 创建一个文件在 config/routes/webgriffe_sylius_back_in_stock_notification_plugin.yaml 中导入插件路由,以下内容

    webgriffe_sylius_back_in_stock_notification_plugin:
      resource: "@WebgriffeSyliusBackInStockNotificationPlugin/Resources/config/routing.yaml"
  4. 在您的 config/packages/webgriffe_sylius_back_in_stock_notification_plugin.yaml 文件中导入所需的配置

    imports:
        - { resource: "@WebgriffeSyliusBackInStockNotificationPlugin/Resources/config/app/config.yaml" }
  5. 通过更新数据库模式和安装资产完成安装

    bin/console doctrine:migrations:diff
    bin/console doctrine:migrations:migrate
    bin/console assets:install
    bin/console sylius:theme:assets:install

配置

此模块使用 Symfony 命令发送邮件。不幸的是,命令行上下文不了解您的虚拟主机或域名。为了解决这个问题,您需要配置“请求上下文”,这是一个花哨的说法,意味着您需要配置环境,使其知道生成 URL 时应使用什么 URL。有关更多信息,请参阅Symfony 文档

  1. 编辑 config/services.yml 文件,添加以下内容
parameters:
    router.request_context.host: example.org
    router.request_context.scheme: https
  1. 如前所述,此模块提供了一个检查产品库存的命令。您需要将命令 bin/console webgriffe:back-in-stock-notification:alert 设置在 crontab 中,每天一次就足够了
0 12 * * * <absolute-php-path> <absolute-path-to-sylius-dir>/bin/console webgriffe:back-in-stock-notification:alert

可选配置

如果您想使用我们定义的 Behat 步骤,您必须将我们的 Behat 类包含在您的 autoloader-dev 中。为此,请将以下行添加到您的 composer.json

"autoload-dev": {
    "psr-4": {
      "Tests\\Webgriffe\\SyliusBackInStockNotificationPlugin\\": "vendor/webgriffe/sylius-back-in-stock-notification-plugin/tests/"
    }
},

贡献

要为此插件做出贡献,请克隆此存储库,为您的功能或错误修复创建一个分支,进行更改,然后确保所有测试都通过。

```bash
(cd tests/Application && yarn install)
(cd tests/Application && yarn build)
(cd tests/Application && APP_ENV=test bin/console assets:install public)

(cd tests/Application && APP_ENV=test bin/console doctrine:database:create)
(cd tests/Application && APP_ENV=test bin/console doctrine:schema:create)
```

要设置插件数据库,请记住在 tests/Application/.envtests/Application/.env.test 中配置您的数据库凭证。

运行插件测试

  • PHPUnit
vendor/bin/phpunit
  • PHPSpec

    vendor/bin/phpspec run
  • Behat(非 JS 场景)

    vendor/bin/behat --strict --tags="~@javascript"
  • Behat(JS 场景)

    1. 安装 Symfony CLI 命令.

    2. 启动无头 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
    3. 安装 SSL 证书(仅需要一次)并在 127.0.0.1:8080 上运行测试应用程序的 web 服务器

      symfony server:ca:install
      APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon
    4. 运行 Behat

    ```bash
    vendor/bin/behat --strict --tags="@javascript"
    ```
    
    • 静态分析

      • Psalm

        vendor/bin/psalm
      • PHPStan

        vendor/bin/phpstan analyse -c phpstan.neon -l max src/
    • 编码标准

      vendor/bin/ecs check src

使用您的插件打开 Sylius

  • 使用 test 环境

    (cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load)
    (cd tests/Application && APP_ENV=test bin/console server:run -d public)
  • 使用 dev 环境

    (cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load)
    (cd tests/Application && APP_ENV=dev bin/console server:run -d public)

许可证

此插件受 MIT 许可证保护。请参阅 LICENSE 文件中的完整许可证。

致谢

Webgriffe® 开发。