How do I filter $Product on AdditionalCategories in the template?
I've tried:
$Product.filter('AdditionalCategories', $MyFilter)
But there is no AdditionalCategories column on Product in the database
How do I filter $Product on AdditionalCategories in the template?
I've tried:
$Product.filter('AdditionalCategories', $MyFilter)
But there is no AdditionalCategories column on Product in the database
With the help of @3dgoo,
Looks like I needed the following:
<% loop $Products.filter('Product_ProductCategories.ProductCategoryID', $MyFilter) %>
Product
has a many to many relationship to ProductCategory
called ProductCategories
.
If we want to filter products on the category relationship we would call the following:
$Product.filter('ProductCategories.ID', 5)
I would recommend writing this filter in a function in a controller. Something like this:
public function getFilteredProducts() {
return Product::get()->filter('ProductCategories.Title', 'my-filter');
}
With the help of @3dgoo,
Looks like I needed the following:
<% loop $Products.filter('Product_ProductCategories.ProductCategoryID', $MyFilter) %>
© 2022 - 2024 — McMap. All rights reserved.