Skip to content

Implement store filter on comma seperated store Id values in Magento grid list

My blog post table contains a store_ids field, which stores store IDs as comma-separated for each blog.

enter image description here

<filterSelect name="store_ids" provider="${ $.parentName }" component="Magento_Ui/js/form/element/ui-select" template="ui/grid/filters/elements/ui-select">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filterOptions" xsi:type="boolean">true</item>
                    <item name="levelsVisibility" xsi:type="number">1</item>
                </item>
            </argument>
            <settings>
                <options class="MageplazaBlogUiComponentListingColumnStoreStoreViewOptions"/>
                <caption translate="true">All Store Views</caption>
                <label translate="true">Store View</label>
                <dataScope>store_ids</dataScope>
                <imports>
                    <link name="visible">componentType = column, index = ${ $.index }:visible</link>
                </imports>
            </settings>
        </filterSelect>

This is filter code I used, which is correctly showing the store views.

enter image description here

Currently, only blog posts assigned to a single store are being filtered. How can I implement a filter that works with the store_ids field, which contains comma-separated store IDs? For example, if I filter by store ID 1, I want to display both blogs.