Forum
Show product on sub category page only
If you've got categories with sub categories created in Runway, can you display a product on a sub category page only?
Currently, I've got the following category structure in a set called 'category':
Cat A
Sub Cat of A
Sub Sub Cat of A
I've created a collection and added a product, choosing the following as the category to display in:
Cat A > Sub Cat of A > Sub Sub Cat of A
On my php page I've got:
// LEVEL 3
if (perch_get('cat') && perch_get('cat2') && perch_get('cat3')) {
perch_collection('Product Groups', array(
'category'=> array('category/'.perch_get('cat').'/'.perch_get('cat2').'/'.perch_get('cat3'))
));
}
// LEVEL 2
elseif (perch_get('cat') && perch_get('cat2')) {
perch_collection('Product Groups', array(
'category'=> array('category/'.perch_get('cat').'/'.perch_get('cat2'))
));
}
// LEVEL 1
elseif (perch_get('cat')) {
perch_collection('Product Groups', array(
'category'=> array('category/'.perch_get('cat'))
));
}
When I come to view the category pages, the product shows in all three of these, so appears on Cat A page, Sub Cat of A page and Sub Sub Cat of A page. I need the product to appear only on Sub Sub Cat of A page.
Do I need to add any further filtering?
At the moment, categories return all decedents, not just children. I'll look and see if we can add an option to change that behaviour.
Thanks Drew.
I've managed a workaround for now by doing a check for the category URL stored in categories, and the URL of the category stored in the collection. If they match, the product is shown.
Ok, great.