I’m trying to create some functionality that allows me to arbitrarily show a collection of products based on criteria such as Category and Attribute values and have this working as intended, however I’d also like to be able to exclude certain Categories so that I could then include the ‘Default Category’ and then exclude any sub categories I don’t want. There doesn’t appear to be a method such as the addCategoryFilter($catid) for this.
I found a similar question that had been answered but couldn’t get it to work for me.
$catId = 9;
/* I'm almost positive 'e' is the alias used for catalog_product_entity, check your
query with echo (string) $products->getSelect(); if it doesn't work */
$products->getSelect()->join(array('cats' => 'catalog_category_product'), 'cats.product_id = e.entity_id');
$products->getSelect()->where('cats.category_id', array('neq' => $catId));
Has anyone else had any experience of doing this kind of thing?
I don’t think there is a native way of doing it. But you can easily make a quick module that extends
and then you can create your own method, and change the joinCondition to suit