Jump to content

Bulk action in new tab


Recommended Posts

Hi everyone, through the documentation I was able to create a custom bulk action to generate a particular PDF for an order.

The problem is that I have to open this operation in a new tab / window, but I have been working on it for 2 days and I have not come out of it.

I also tried to replicate the Bulk Action that is already there but by default (open an order in a new tab) but I get a JS error that the route does not exist (which instead normally works correctly).

Do you have any suggestions / material / documentation to draw inspiration from?

Thank you

Link to comment
Share on other sites

Could you maybe share what you already have?

I'm also trying to make a bulk action, that would download a CSV file of orders. Im coming so far to make the CSV but i can't get it to acually serve me a CSV file with a normal SubmitBulkAction feature.

I am also tryint using the ButtonBulkAction, but got the same JS error as you, sadly

this is the part for me that gives a "print_r" result of the orders and detail i need in my csv.

$params['definition']->getBulkActions()->add(
            (new SubmitBulkAction('mymodule_export_csv'))
                    ->setName($this->l('Export Order CSV'))
                    ->setOptions([
                        // in most cases submit action should be implemented by module
                        'submit_route' => 'mymodule_export_csv',
                    ])
        );

this is the ButtonBulkAction version i tries to do same with but gives the JS error

$params['definition']->getBulkActions()->add((new ButtonBulkAction('mymodule_export_csv'))
           ->setName($this->l('Export Order CSV'))
           ->setOptions([
               'class' => 'open_tabs',
               'attributes' => [
                   'data-route' => 'mymodule_export_csv',
                   'data-route-param-name' => 'orderId',
                   'data-tabs-blocked-message' => $this->l('It looks like you have exceeded the number of tabs allowed. Check your browser settings to open multiple tabs.')
               ],
           ])
       );

 

Edited by Casper_O (see edit history)
Link to comment
Share on other sites

Hello Casper,

i have similar code:

$params['definition']->getBulkActions()->add(
            ( new SubmitBulkAction( 'packaging_list_printing' ) )
                ->setName( 'PDF packaging list' )
                ->setOptions( [
                    'submit_route' => 'admin_packaginglist_orders_bulk_print',
                ] ) 
        );

and in the module i have created a folder "config" with inside a "route.yml" file like this:

admin_packaginglist_orders_bulk_print:
  path: /packaging-list/print
  methods: [POST,GET]
  defaults:
    _controller: 'PrestaShop\Module\PackagingList\Controller\Admin\PackagingListPrintController::listAction'
    exposed: true

This works fine BUT i can't open this route in a new tab/browser windows like this.

I also tried this:

$link = New Link();
        $symfonyUrl = $link->getAdminLink(
            'PackagingListPrintController', 
            true, 
            array( 'route' => 'admin_packaginglist_orders_bulk_print' )
        );
        $params['definition']->getBulkActions()->add(
            (new ButtonBulkAction('packaging_list_printing'))
                ->setName('PDF packging NEW TAB')
                ->setOptions([
                    'class' => 'open_tabs',
                    'attributes' => [
                        'data-route' => $symfonyUrl,
                        'data-route-param-name' => '',
                        'data-tabs-blocked-message' => 'It looks like you have exceeded the number of tabs allowed. Check your browser settings to open multiple tabs.',
                    ],
                ])
        );

but i get a JS error "admin_packaginglist_orders_bulk_print route not found".

No solutions for me now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...