বিভিন্ন উপায়ে চেষ্টা করার পরে, এই একমাত্র সমাধানটি আমি খুঁজে পেতাম যা অন্য মডিউলগুলিকে প্রভাবিত না করেই কাজ করে বলে মনে হচ্ছে। আমি অন্যান্য সমাধান দেখতে চাই।
বিকল্প 1
সংস্থা / মডিউল / ইত্যাদি / প্রশাসনিক / 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="MagePal_TestBed::pluginBefore" type="MagePal\TestBed\Plugin\PluginBefore" />
</type>
</config>
তারপরে প্লাগইন / প্লাগইনবিফোর.এফপি
namespace MagePal\TestBed\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' => __('My Button'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'],
-1
);
}
}
}
বিকল্প 2
সংস্থা / মডিউল / ইত্যাদি / প্রশাসনিক / di.xML এ একটি প্লাগইন তৈরি করুন
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="\Magento\Sales\Block\Adminhtml\Order\View">
<plugin name="MagePal_TestBed::pluginBeforeView" type="MagePal\TestBed\Plugin\PluginBeforeView" />
</type>
</config>
তারপরে প্লাগইন / প্লাগইনবিফরভিউ.এফপি
namespace MagePal\TestBed\Plugin;
class PluginBeforeView
{
public function beforeGetOrderId(\Magento\Sales\Block\Adminhtml\Order\View $subject){
$subject->addButton(
'mybutton',
['label' => __('My Buttion'), 'onclick' => 'setLocation(window.location.href)', 'class' => 'reset'],
-1
);
return null;
}
}
দেখুন ফুল সোর্স কোড