My custom model collection has a database table that contains store_ids value separated by comma like this:
ID | store_ids |
+++++++++++++++++
1 | 0,1,3 |
2 | 1 |
3 | 0,1 |
4 | 0,2 |
5 | 3 |
I'm using this input field to save the store_ids in the backend:
i noticed the 0
value is the default value , and the rest is the specific store ids value. My question is , how can i retrieve by the current store id, and prioritize the record that has the single store id value, for example with store_id = 1
it will retrieve the record with ID 2
?
i tried this, but this filter can not give the specific store_id as first priority :
->addFieldToFilter(
'visible_stores',
[
[
array('like' => '%'.$this->getStoreId().'%')
],
[
array('like' => '%0%')
]
]
);