2

我希望要求不要吝啬事情不要太苛刻。

开始了:

我在为 Shopware 5 开发自定义插件时遇到问题。我已经有一个工作插件,它列出了特定标准的订单。现在我想在这个网格窗口的工具栏中有一个按钮(我已经有了)。

该按钮应打开批处理窗口,该窗口已在商店商品的本机“订单”窗口中可用。

问:如何使用我选择的网格 ID 打开这个应用程序?

这是我所拥有的:

[...]
createToolbarButton: function () {
        var me = this;
        return Ext.create('Ext.button.Button', {
            text: 'Batch Processing Orders',
            name: 'customBatchProcessButton',
            cls: 'secondary',
            handler: function () {
                me.onClickCustomBatchProcessButton(me);
            }
        });
    },
onClickCustomBatchProcessButton: function(me){
        var thisGrid = me.getTransferGrid();
        var records = thisGrid.getSelectionModel().getSelection();
        console.log("Grid");
        console.log(thisGrid);
        console.log("records");
        console.log(records);
        Shopware.app.Application.addSubApplication({
             name: 'Shopware.apps.Order',
             action: 'batch',
             params: {
                 mode: 'multi',
                 records: records
             }
         });
    }
[...]

它总是打开订单窗口的正常视图。(控制台没有错误)有人有建议吗?那很好啊!谢谢你的时间 :)

问候

编辑:嘿,谢谢你到目前为止的回复。我设法像这样打开批处理窗口:

me.getView('Shopware.apps.Order.view.batch.Window').create({
                 orderStatusStore: Ext.create('Shopware.apps.Base.store.OrderStatus').load(),
                 records: orderRecords,
                 mode: 'multi'
             }).show({});

但现在问题是,批处理的事件没有应用到表单上的按钮上......我仍在尝试和错误。

4

1 回答 1

1

许多 Shopware ExtJS 子应用程序可以完全按照您尝试的方式从具有某些参数的另一个应用程序执行。不幸的是,我在 Order 插件中没有看到任何可能导致所需结果的代码。init您可以通过阅读主控制器 的功能来查看 Shopware 子应用程序支持哪些操作/参数->Shopware.apps.Order.controller.Main

Shopware.apps.Customer.controller.Main例如,来自客户插件的接受一个动作,就像你正在使用它一样——它正在检查这个:

if (me.subApplication.action && me.subApplication.action.toLowerCase() === 'detail') {
    if (me.subApplication.params && me.subApplication.params.customerId) {
        //open the customer detail page with the passed customer id
...

在订单插件中也有类似的代码,但它只需要一个订单 ID 并打开相应订单的详细信息页面。它显然没有batch.Window

你也许可以以某种方式重用这个类,但这可能是你需要从实际的 Order 插件改编的大量代码。如果你真的需要这个功能,你可以仔细阅读 Order 插件是如何初始化窗口及其依赖的,然后尝试一下。

我宁愿在这种情况下开发一个轻量级模块(它是后端窗口中的一个框架,它只使用控制器和带有 PHP/Smarty/HTML 的模板视图)

于 2017-02-22T01:59:59.433 回答