We are upgrading a webshop so the filtering is a little bit different. Now we simply get all product ID's which are related to one or more selected filter values.
//Filter value '8 GB'
$result[] = array(1,6,5,8,9);
//Filter value 'AMD E' (and)OR 'INTEL'
$result[] = array(1,5,8,9,10,500,502,503,600,607,608,...);
The 'AMD E' and 'INTEL' values are from the same filter 'Processor' so we would like these combined as the visitor would like to have all products with an AMD E OR an INTEL processor.
Now we would like to select only the ID's which occur in both array's. We've tried a bunch of methods by now it just doesn't return what we expect in any atempt.
The problem is that the number of key => array pairs in $result
is dynamic just like the number of ID's returned by SQL. when the first array in $result
is a short list of ID's, array_intersect()
will not return all expected results when there are multiple array's in $result
.
merge_array()
would just combine everything. So the visitor will see ALL products which have 8 GB memory or which contain a AMD E or INTEL processor.
We are looking for a ('8 GB') AND ('ADM E' OR 'INTEL') solution.
Things get complicated when more filters are activated: ('8 GB' OR '12 GB') AND ('ADM E' OR 'INTEL') AND ('HP' OR 'Apple' OR 'Sony')
(Hope I didn't loose you trying to explain the situation and what we are trying to do by now :s)
We've also tried getting stuff done through SQL. As you can read in this question without any luck.
Anyone tackled something like this before?