I have tried to add Category column in Product grid admin area.I have added it successfully by below code.
<column name="category" class="Chilly\Productsgrid\Ui\Component\Listing\Column\Category">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Chilly\Productsgrid\Model\Category\Categorylist</item>
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">select</item>
<item name="dataType" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Categories</item>
<item name="sortOrder" xsi:type="number">50</item>
</item>
</argument>
</column>
In Chilly\Productsgrid\Ui\Component\Listing\Column\Category.php, prepareDataSource() method
$fieldName = $this->getData('name');
if (isset($dataSource['data']['items'])) {
//$categories=array();
foreach ($dataSource['data']['items'] as & $item) {
$p_id=$item['entity_id'];
$product=$this->_productloader->create()->load($p_id);
$cats = $product->getCategoryIds();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$categories=array();
if(count($cats) ){
foreach($cats as $cat){
$category = $objectManager->create('Magento\Catalog\Model\Category')->load($cat);
$categories[]=$category->getName();
}
}
$item[$fieldName]=implode(',',$categories);
}
}
return $dataSource;
Got Categories list in product grid. I have tried the following code for add filter,
<item name="filter" xsi:type="string">select</item>
and for add options to category filter dropdown,
<item name="options" xsi:type="object">Chilly\Productsgrid\Model\Category\Categorylist</item>
category dropdown came in filter section. But not add categories list to category dropdown. Have any idea, How to add category filter on product grid in magento2?