Filter Page List By multiple select Attribute


I am trying to filter a page list using a select attribute with contains multiple values. here are a few ways i've tried. None works so far. This is within my block controller.

$cPage = $this->getCollectionObject();
$pak = CollectionAttributeKey::getByHandle('spot_programs');
$att_progs = $cPage->getAttribute($pak);
$pl = new PageList();
//Method 1. Only works with one item in select
$pl->filterByAttribute('spot_programs', "%{$att_progs}%" , 'like');
//Method 2.  Only works with one item in select. with multiple select items $pl->debug() shows ak_spot_program is nested with AND instead of OR. still NO Good.
foreach($ary_progs_vals as $val) {      

I could use some ideas,

View Replies:
rainmaker replied on at Permalink Reply
May want to check out this from what I've asked before:

With multiple attributes, there's a \n in there. Never figured out why...
dwayneparton replied on at Permalink Reply
Well this is late but I figured out how to do this.
The filterBySelectAttribute() function actually can handles arrays. You don't need to do anything special. The code below should work.

Here is the documentation from the Model:
Like filterByAttribute(), but wraps values properly for "select" type attributes. Accepts either a single value, or an array of values. If an array of values is provided, they will be combined together with "OR". (If you need to do an "AND" filter on mulitple values, just call this function multiple times).

$cPage = $this->getCollectionObject();
$akHandle = 'spot_programs';
$pak = COllectionAttibuteKey::getByHandle($akHandle);
$value = $cPage->getAttribute($pak);
$pl = new PageList();
$pl->filterBySelectAttribute($akHandle, $value);