How to override or disable core Plugins in Magento2?
1) You can disable plugin by name. In your case it authorization
.
Edit: The syntax of this method doesn't work in the modern version of magento, see fudu's answer below or go to the second method.
<type name="Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization">
<plugin name="authorization" disabled="true" />
</type>
<type name="Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization">
<plugin name="vendor_name_authorization" type="Vendor\Name\Model\ResourceModel\Plugin\Sales\Order\Authorization" sortOrder="1" />
</type>
Then you should create own class, which will extend the magento plugin class. In own class you can overwrite protected method.
2) You can do it without delete and recreate plugin:
<type name="Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization">
<plugin name="authorization" type="Vendor\Name\Model\ResourceModel\Plugin\Sales\Order\Authorization" sortOrder="1" />
</type>
Sample code of your plugin class:
namespace Vendor\Name\Model\ResourceModel\Plugin\Sales\Order;
class Authorization extends \Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization
{
protected function isAllowed(\Magento\Sales\Model\Order $order)
{
///You code here
}
}
If you use sergei.sss 1st solution, you will get the error of duplicate Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization
The correct way to do that is:
<type name="Magento\Sales\Model\ResourceModel\Order\Plugin\Authorization">
<plugin name="authorization" disabled="true" />
<plugin name="vendor_name_authorization" type="Vendor\Name\Model\ResourceModel\Plugin\Sales\Order\Authorization" sortOrder="1" />
</type>