2

I hope its not to harsh to ask not to mince matters.

Here we go:

I have a problem developing a custom Plugin for Shopware 5. I already have a working plugin which lists orders for certain criteria. Now I want a Button (which i already have) in the toolbar of this grid-window.

The Button should open the Batch Process Window which is already available in the native "Order" Window of shopware.

Q: How Can I open this app with the selected Ids of my grid?

Heres what I have:

[...]
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
             }
         });
    }
[...]

It always opens the normal view of the order window. (no error in console) Anybody has a suggestions? That would be great! Thanks for your time :)

Greetings

EDIT: Hey, thank you for your reply so far. I managed to open the Batch-process-window like this:

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

But now the Problem ist, the Event for the Batch-Process isn't applied on the button on the form... I am still on try and error.

exa.byte
  • 155
  • 1
  • 12

1 Answers1

1

Many Shopware ExtJS SubApplications can be executed from another app with certain parameters exactly the way you're trying to. Unfortunately I don't see any code in the Order plugin that might lead to the desired result. You can see what actions/params a Shopware SubApplication supports by reading the init function of the main controller -> Shopware.apps.Order.controller.Main

Shopware.apps.Customer.controller.Main from the Customer plugin for example accepts an action like you are using it – it is checking for this:

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
...

In the Order plugin there is similar code, but it just takes an order ID and opens the detail page for the corresponding order. It apparently doesn't feature the batch.Window

You might be able to reuse this class somehow, but that might be a ton of code you need to adapt from the actual Order plugin. If you really need this feature, you can carefully read how the Order plugin is initializing the window and its dependencies and have a try.

I'd rather go for developing a lightweight module in this scenario (It's a frame within a backend window that just uses controllers and template views with PHP/Smarty/HTML)

nether_cat
  • 122
  • 1
  • 7