- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am new to magento. I want to add Dispatch button to Order view page (Admin) and would like to write funtionality it. Please help me out in this ASAP.
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
Check the below link.
add-custom-button-admin-sales-order-view-page-magento-2/
add-a-custom-button-to-admin-sales-order-view-magento-2/
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
Create a plugin in Company/Module/etc/adminhtml/di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Backend\Block\Widget\Button\Toolbar"> <plugin name="Vendor_Model::pluginBefore" type="Vendor\Model\Plugin\PluginBefore" /> </type> </config>
Then add code with Plugin/PluginBefore.php
namespace Vendor\Modelname\Plugin; class PluginBefore { public function beforePushButtons( \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject, \Magento\Framework\View\Element\AbstractBlock $context, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList ) { $this->_request = $context->getRequest(); if($this->_request->getFullActionName() == 'sales_order_view'){ $buttonList->add( 'mybutton', ['label' => __('Dispatch'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'], -1 ); } } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
Glad to hear that, it works for you!
For order status change, follow the below link.
https://magento.stackexchange.com/a/164613
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
You can follow below link to create an admin controller.
magento-2-how-to-create-an-admin-controller-and-a-new-acl/
Then you can call this controller from the button you have created.
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
Check the below link.
add-custom-button-admin-sales-order-view-page-magento-2/
add-a-custom-button-to-admin-sales-order-view-magento-2/
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Add custom buttons to admin order view page and write funtionality to it
Hi Vimal,
Thanks for your valuable reply. I have created button but now i am redirecting to custom index Controller. In controller i want to change order status to Dispatched and want to send Email regarding. Please help me on this also
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
Create a plugin in Company/Module/etc/adminhtml/di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Backend\Block\Widget\Button\Toolbar"> <plugin name="Vendor_Model::pluginBefore" type="Vendor\Model\Plugin\PluginBefore" /> </type> </config>
Then add code with Plugin/PluginBefore.php
namespace Vendor\Modelname\Plugin; class PluginBefore { public function beforePushButtons( \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject, \Magento\Framework\View\Element\AbstractBlock $context, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList ) { $this->_request = $context->getRequest(); if($this->_request->getFullActionName() == 'sales_order_view'){ $buttonList->add( 'mybutton', ['label' => __('Dispatch'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'], -1 ); } } }
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
Glad to hear that, it works for you!
For order status change, follow the below link.
https://magento.stackexchange.com/a/164613
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Add custom buttons to admin order view page and write funtionality to it
Thank you for valuable post. Please let me how to create controller on this write functionality for Dispatch event. Please help
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Add custom buttons to admin order view page and write funtionality to it
Thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Add custom buttons to admin order view page and write funtionality to it
Hi @tippanna_pawar
Can you tell me that all resolved or need any help?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Add custom buttons to admin order view page and write funtionality to it
Hi vimal,
Still i am in problem. Can you guide me how to create controller on above click event. what could be the controller link for button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @tippanna_pawar
You can follow below link to create an admin controller.
magento-2-how-to-create-an-admin-controller-and-a-new-acl/
Then you can call this controller from the button you have created.
I hope it will help you!