Jump to content

Create order grid/row actions - Prestashop 1.7.7


Recommended Posts

Hi,

With the newest version of Prestashop both the order grid page & order page have been significantly updated. I have tried following the docs explaining how to add custom actions to the order grid, but I cannot for the life of me get it to work properly.

These are the docs I have been referring to:
https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/work-with-row-actions/
https://devdocs.prestashop.com/1.7/development/components/grid/actions-reference/
https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/work-with-grid-actions/

What I basically want to achieve, which I had no problem with before, is to add to extra grid actions that generates an XML-file. To apply the functionality I have created a custom module which has a controller called AdminXmlController that generates the file. However that does not seem to be straight forward with the new way of implementing similar functionality.

I have attached an image where I have marked the place where I want to have two additional icons, that should call a method/action within my controller that is placed in mymodule/controllers/admin/AdminXmlController.php. Can someone point me in the direction of how I am going to achieve this?

I have tried something similar to this is my main module file:

  public function hookActionOrderGridDefinitionModifier(array $params) {
    /** @var \PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinition */
    $gridDefinition = $params['definition'];
    $gridDefinition->getGridActions()
        ->add((new LinkGridAction('send_freight_xml'))
        ->setName($this->trans('Send shipping', [], 'FreightModule.Admin.Actions'))
        ->setIcon('send') // icon from https://materializecss.com/icons.html by default
        ->setOptions([
            'route' => 'admin_xml_generate_order_xml',
            'route_params' => ['id_order']
        ])
    );
  }

With the code above I guess i need to register the route etc., but the docs seem to be very inadequate explaining how to achieve this.

Any help would be much appreciated.

519741887_Screenshot2020-12-28at11_45_55.thumb.png.93799c647080b5c63f3195c2b01369a5.png

Share this post


Link to post
Share on other sites
  • 1 month later...

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

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More