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

此包已被弃用且不再维护。未建议替代包。

产品重新上架时及时通知客户和访客

1.1.3 2023-01-23 09:05 UTC

This package is auto-updated.

Last update: 2023-01-23 09:09:13 UTC


README

68747470733a2f2f64656d6f2e73796c6975732e636f6d2f6173736574732f73686f702f696d672f6c6f676f2e706e67

库存恢复通知插件

当产品恢复库存时,允许通过电子邮件接收通知的插件

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® 开发。