yaroslavche/sylius-exchange-rates-updater-plugin

Sylius 汇率更新控制台命令。

This package is auto-updated.

Last update: 2024-09-06 09:27:51 UTC


README

bin/console sylius:exchange-rates:generate

此命令从Sylius提供的货币中生成所有可用的唯一货币对。

更新汇率

bin/console sylius:exchange-rates:update

此命令尝试更新Sylius中所有现有的汇率。

安装

composer require yaroslavche/sylius-exchange-rates-updater-plugin

注册插件

# app/AppKernel.php

# ...
public function registerBundles(): array
{
    $bundles = [
        # ...
        new \Acme\SyliusExchangeRatesUpdaterPlugin\AcmeSyliusExchangeRatesUpdaterPlugin(),
    ];
    #...
}

导入服务配置

#app/config/config.yml

imports:
    # ...
    - { resource: '@AcmeSyliusExchangeRatesUpdaterPlugin/Resources/config/services.yml' }
    # ...

并添加参数

#app/config/parameters.yml
parameters:
    # ...
    
    exchange_rates_updater_plugin.openexchangerates: 'your_api_key'
    exchange_rates_updater_plugin.fixer: 'your_api_key' # not used now

用法

对于每日更新,将以下内容添加到crontab中

0 0 * * * /path_to_sylius/bin/console sylius:exchange-rates:update