:::: MENU ::::

Magento 2 Find value comma separated string column

Magento 2 Find value in comma separated string column

Today we discuss Magento 2 find value comma separated string column. Sometime you need to search in comma separated values in database. So for that we use the Finset to search in comma separated values. Let’s take the example of product collection. Let’s spose the field name test_sku have the comma separated values. So here is example.

protected $_productCollectionFactory;
public function __construct(
        \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productFactory
    ) {
        $this->_productCollectionFactory = $productFactory;
    public function getProductCollection()
      return   $this->_productCollectionFactory->create()->addFieldToFilter('test_sku', array('finset' => $sku));
Author: Qaisar Satti
Category: Magento 2
Last Modified: July 12, 2018

So, what do you think ?