i am using a plugin to filter products on admin panel by product attribute, but got no results. here is my plugin code.
<?php
namespace Learning\HelloPage\Plugin;
class ProductDataProvider
{
public function aftergetData(\Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider $subject
)
{
if (!$subject->getCollection()->isLoaded()) {
echo 'jhsdg';
$subject->getCollection()->addFieldToFilter('admin_user_id', array('eq' => '2')); //replace with dynamic admin user from session
$subject->getCollection()->load();
echo 'sghd';
}
}
}
and my etc/di.xml file
<?xml version="1.0"?>
<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="productdata" type="Learning\HelloPage\Plugin\ProductDataProvider" />
</type>
</config>
what am i doing wrong? please suggest any solution