Magento Asked by SebastianT on October 2, 2021
I’ve followed this link to add custom button in Admin Sales Order View in Magento 2, and it works great. Now I want to replace this button with 3 dropdown options button. Something like changing store scope in Admin Panel. I want this 3 buttons to run same controller method with different parameters.
How can i achieve this?
Thanks in advance.
This code works for me , try to look splitButton
class ViewPlugin
{
public function beforeSetLayout(
MagentoView $view,
LayoutInterface $layout
) {
$addButtonProps = [
'id' => 'test',
'label' => __('Test'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->getCustomActionListOptions(),
];
$view->addButton('test',$addButtonProps);
}
protected function getCustomActionListOptions()
{
/*list of button which you want to add*/
$splitButtonOptions=[
'action_1'=>['label'=>__('Action 1'),'onclick'=>'setLocation("ACTION 1")'],
'action_2'=>['label'=>__('Action 2'),'onclick'=>'setLocation("ACTION 2")'],
'action_3'=>['label'=>__('Action 3'),'onclick'=>'setLocation("ACTION 3")']
];
return $splitButtonOptions;
}
}
<type name="MagentoSalesBlockAdminhtmlOrderView">
<plugin name="addMyButton" type="MyModulePluginBlockAdminhtmlOrderView"/>
</type>
Correct answer by Kai on October 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP