Details
-
Type:
Improvement
-
Status:
In Progress
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.3.1
-
Fix Version/s: None
-
Component/s: None
-
Security Level: All
-
Labels:
Description
The recently added collection filtering API only goes half way in achieving a full fledged solution to filter huge collections. It still lacks joins. Look at the next two snippets:
$criteria = Criteria::create()
->where(Criteria::expr()->eq('storeId', $store->getId()))
->andWhere(Criteria::expr()->eq('Category', 20))
->orderBy(array('popularity' => 'DESC'));
return $this->BrandCategories->matching($criteria);
This piece of code works but what if there is a need to filter the BrandCategories collection by Categories with some extra criteria:
$criteria = Criteria::create()
->where(Criteria::expr()->eq('storeId', $store->getId()))
->andWhere(Criteria::expr()->eq('Category', 20))
->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
->orderBy(array('popularity' => 'DESC'));
return $this->BrandCategories->matching($criteria);
That would not work.
Ideally we should have a possibility to join other entities, the Category entity in our case here:
$criteria = Criteria::create()
->where(Criteria::expr()->eq('storeId', $store->getId()))
->andWhere(Criteria::expr()->eq('Category', 20))
->innerJoin(Criteria::expr()->field('Category', 'Category'))
->andWhere(Criteria::expr()->eq('Category.name', 'Electronics'))
->orderBy(array('popularity' => 'DESC'));
return $this->BrandCategories->matching($criteria);
What do you think about it, does it make sense to add such functionality?