示例#1
0
 /**
  * Return the filter applied to the query.
  *
  * @SuppressWarnings(PHPMD.ElseExpression)
  *
  * @return QueryInterface
  */
 private function getQueryFilter()
 {
     $queryParams = [];
     $this->category->setIsActive(true);
     if ($this->category->getIsVirtualCategory() || $this->category->getId()) {
         $queryParams['must'][] = $this->category->getVirtualRule()->getCategorySearchQuery($this->category);
     } elseif (!$this->category->getId()) {
         $queryParams['must'][] = $this->getEntityIdFilterQuery([0]);
     }
     if ((bool) $this->category->getIsVirtualCategory() === false) {
         $addedProductIds = $this->category->getAddedProductIds();
         $deletedProductIds = $this->category->getDeletedProductIds();
         if ($addedProductIds && !empty($addedProductIds)) {
             $queryParams = ['should' => $queryParams['must']];
             $queryParams['should'][] = $this->getEntityIdFilterQuery($addedProductIds);
         }
         if ($deletedProductIds && !empty($deletedProductIds)) {
             $queryParams['mustNot'][] = $this->getEntityIdFilterQuery($deletedProductIds);
         }
     }
     return $this->queryFactory->create(QueryInterface::TYPE_BOOL, $queryParams);
 }