ErJay Posted February 4, 2022 Share Posted February 4, 2022 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 More sharing options...
Casper_O Posted February 6, 2022 Share Posted February 6, 2022 (edited) 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 February 6, 2022 by Casper_O (see edit history) Link to comment Share on other sites More sharing options...
ErJay Posted February 10, 2022 Author Share Posted February 10, 2022 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 More sharing options...
Casper_O Posted February 10, 2022 Share Posted February 10, 2022 @ErJay could you maybe also share your PackagingListPrintController::listAction ? I can't get it to return a CSV file, i just get an ERROR 500 or alternative it redirect me to the order view list again. Belive it should work same way, as how you did your PDF return. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now