I want to override a method from a Ui component which sets filter values. My Plugin code
<?php
namespace MyVendor\MyModule\Plugins\DataProvider\Product;
class GiftProvider
{
public function aroundAddFilter(
$subject,
\Closure $proceed,
\Magento\Framework\Api\Filter $filter
)
{
if (isset($subject->addFilterStrategies[$filter->getField()])) {
$subject->addFilterStrategies[$filter->getField()]
->addFilter(
$subject->getCollection(),
$filter->getField(),
[$filter->getConditionType() => $filter->getValue()]
);
} else {
$abstractProvider::addFilter($filter);
}
if(!isset($subject->addFilterStrategies['is_gift']))
{
$subject->addFilterStrategies['is_gift']
->addFilter(
$subject->getCollection(),
'is_gift',
[$filter->getConditionType() => 1]);
}
return $subject;
}
}
etc/adminhtml/di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider">
<plugin name="gift_data_provider_around_plugin" type="MyVendor\MyModule\Plugins\DataProvider\Product\GiftProvider" sortOrder="1500" />
</type>
</config>
Ajax returns
Fatal 500 Internal Server Error
And a message is outputted saying :
"Attention
Something went wrong."
What did go wrong is that the response of the ajax is empty when I inspect it.
Where is my mistake, Is this possible ?