简体   繁体   English

Magento 2“创建”按钮,位于“管理面板”中的“订单”部分

[英]Magento 2 Create button on order section in Admin Panel

enter image description here 在此处输入图片说明

I am very new to magento 2. I want to create a button on the admin's sales panel eg change State. 我是magento 2的新手。我想在管理员的销售面板上创建一个按钮,例如,更改状态。 It's functionality will be similar to the hold or unhold button that if i click the button, the order status will be changed to myState. 它的功能将类似于保留或取消保留按钮,如果我单击该按钮,则订单状态将更改为myState。 However, i get to the point that confuse me is how i can customize my own function of the button. 但是,我感到困惑的是如何自定义按钮的功能。

I created the button like this on View.php enter image description here 我在View.php上创建了这样的按钮,请在此处输入图片描述

However, there is a line with getChangeStateUrl() enter image description here 但是,有一行与getChangeStateUrl()一起在此处输入图片描述

i do not know what is the file located on getUrl("sales/*/change_state") because it seems the file that i need to customize. 我不知道getUrl(“ sales / * / change_state”)上的文件是什么,因为似乎该文件需要自定义。

I found a similar solution on this https://magento.stackexchange.com/a/88949 and add my function on the View.php. 我在此https://magento.stackexchange.com/a/88949上找到了类似的解决方案,并在View.php上添加了我的功能。 Since eg Mage::getModel is not worked on magento 2 so I used $objectManager to change the state and status of the order. 由于例如Mage :: getModel在magento 2上不起作用,因此我使用$ objectManager更改了订单的状态和状态。 However, I do not get to the point of the getUrl so i return to the same page like this. 但是,我没有到达getUrl的要点,所以我回到了相同的页面。

return $this->getUrl('sales/order/view'); 返回$ this-> getUrl('sales / order / view');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM