I have this afterGetList
plugin in
Vendor\Module\Plugin\Magento\Sales\Model\OrderCompanyAccount.php
public function afterGetList(
\Magento\Sales\Api\OrderRepositoryInterface $subject,
$orders
)
{
foreach ($orders->getItems() as $order) {
//do stuff
}
return $orders;
}
And in Vendor\Module\etc\webapi_rest\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\Api\OrderRepositoryInterface">
<plugin name="order_repository" type="Vendor\Module\Plugin\Magento\Sales\Model\OrderCompanyAccount"
disabled="false"
sortOrder="200"/>
</type>
</config>
I want to add another afterGetList
plugin.
Vendor\Module\Plugin\Magento\Sales\Model\OrderComment.php
public function afterGetList(
\Magento\Sales\Api\OrderRepositoryInterface $subject,
$orders
)
{
foreach ($orders->getItems() as $order) {
//do other stuff
}
return $orders;
}
And this time in Vendor\Module\etc\webapi_rest\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\Api\OrderComment">
<plugin name="order_repository" type="Vendor\Module\Plugin\Magento\Sales\Model\OrderComment"
disabled="false"
sortOrder="210"/>
</type>
</config>
If I enable one of these modules, they are working fine. However, if I enable both, none of them are working anymore. I tried with sortOrder
but it has no effect.
So, my question is: How to have more than one afterGetList plugin enabled at the same time? Or better asked: What's the correct way of having two different plugins for one method at all?