cancel
Showing results for 
Search instead for 
Did you mean: 

Adding new buttons in Admin

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Adding new buttons in Admin

I am working on this new module for Magento, that integrates with some local suppliers that provide a dropshipping service for their products.

The module has a feature to get various details from the suppliers system using a webservice.

 

For this I have create some files under app -> Code -> MyVendor -> MyModule -> Controller -> Adminhtml -> Order -> GetDropshippingStatus.php

The contents could be something like this:

<?php

namespace Conviator\AO\Controller\Sales\Order;

class GetDropShippingStatus extends \Magento\Sales\Controller\Adminhtml\Order
{
    public function execute()
    {
        $this->_initOrder();
        // Do what we have to do

        // Redirect back
        $this->_redirect('*/*/view');
    }
}

I have also added a plugin to create the buttons on the Order Details Page/View

The below is an example of a button to trigger the above:

$subject->addButton(
                    'get_dropshipping_status',
                    [
                        'label' => __('Get Dropshipping Order Status'),
                        'onclick' => "confirmSetLocation('" . __('Are you sure you want get status for this order?') . "', '{$subject->getUrl('*/*/getdropshippingstatus')}')",
                        'class' => 'go'
                    ],
                    -1
                );

However, when I click the button inside Magento, it gives me a 404 error page.

 

How should I construct the button to actually hit the code defined previously?