【问题标题】:After upgrade from Shopware 5.6.10->5.7.6, custom console commands are missing从 Shopware 5.6.10->5.7.6 升级后,缺少自定义控制台命令
【发布时间】:2021-12-28 08:54:47
【问题描述】:

我们将用于测试的 Shopware 5 系统从 5.6.10 升级到 5.7.6

现在是控制台命令

hpr:orders:export  

不见了。

这来自一个不再受到官方支持的市场模块 - 问题是是否有一种简单的方法来修补它。

旧安装:

php7.2 ./console |grep hpr
 hpr
  hpr:orders:export                          Starting the export (as defined in the plugin-config) of the orders. Options are mostly the same as the REST-API options.

升级后:

 php7.4 ./console |grep hpr
 (no output)

upgrade guide for 5.7 中,它声明 Symfony 已升级……但没有直接提及与此相关的重大更改。

namespace HPrAutomaticOrderExport\Components;

use Exception;
use Shopware\Commands\ShopwareCommand;
use Shopware\Components\Plugin\ConfigReader;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class CLICommand extends ShopwareCommand
{


    protected function configure()
    {
    $this->setName('hpr:orders:export');
    $this->setDescription('Starting the export (as defined in the plugin-config) of the orders. Options are mostly the same as the REST-API options.');
    $this->addOption('states', null, InputOption::VALUE_OPTIONAL, 'coma seperated list of order-states ids to filter output');
    $this->addOption('statespayment', null, InputOption::VALUE_OPTIONAL, 'coma seperated list of payment-states ids to filter output');
    $this->addOption('range', null, InputOption::VALUE_OPTIONAL, 'date range: startdate,enddate'); //TODO syntax for today - n days would be great!!!!!!
    $this->addOption('start', null, InputOption::VALUE_OPTIONAL, 'start index in list of orders (defaukt is 0, beginning of the list)');
    $this->addOption('limit', null, InputOption::VALUE_OPTIONAL, 'maximal count of orders to export (default is 100)');
    $this->addOption('number', null, InputOption::VALUE_OPTIONAL, 'number of a single order');
    $this->addOption('exportall', null, InputOption::VALUE_OPTIONAL, 'export all orders, ignore states');
    }

插件已启用:

 php7.4 console sw:plugin:list|grep Order
 | HPrAutomaticOrderExport             | Automatic XML Order-Export Standard                                        
 | 3.7.1   | Windeit Software GmbH    | Yes    | Yes       |

services.xml 编辑

    <service id="hp_order_export_command" class="HPrAutomaticOrderExport\Components\CLICommand">
        <tag name="console.command" />
        <argument type="service" id="shopware.plugin.config_reader"/>
        <argument type="service" id="hp_order_export_service"/>
    </service>

更新我们刚刚禁用了该插件,因为我们并不真正需要它 - 我仍然将它留给更多读者。

【问题讨论】:

  • 该命令是否在 services.xml 文件中正确标记和注册?喜欢这里github.com/shopware/shopware/blob/5.7/engine/Shopware/…
  • 啊,控制台“command”属性不见了
  • 您是否尝试过向该插件寻求更新版本的支持?
  • @NicoHaase 该插件不再受支持,因此已从商店中删除...

标签: symfony shopware5


【解决方案1】:

根据 Michael T 的评论:

将标签改为

<tag name="console.command" value="hpr:orders:export"/>

和缓存刷新命令再次显示在控制台中。

【讨论】:

    【解决方案2】:

    升级到 Shopware 5.7.x 后,我在使用此插件时也遇到了一些问题。

    在我的情况下是

    ““hp_order_export_service”服务或别名已被删除或 编译容器时内联。你应该要么做到 public,或者直接停止使用容器并使用依赖 而是注射。”

    我在custom/plugins/HPrAutomaticOrderExport/Resources/services.xml中添加&lt;services&gt;&lt;defaults public="true"/&gt;这一行

    这有帮助,也许它也会帮助其他人。

    【讨论】:

    • 请不要编辑任何插件的源文件。这只会在您稍后更新插件时造成麻烦
    • 插件似乎不再维护了,composer-patches 可能仍然是更好的选择
    • @NicoHaase 这个插件已经死了,应该被替换,因为这个插件没有开发者。所以这不是一个真正的问题。但是在紧要关头改变整个“电子商务平台”并不是那么容易。
    猜你喜欢
    • 2013-10-19
    • 2016-04-10
    • 2022-01-18
    • 2015-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-15
    相关资源
    最近更新 更多