Пример #1
0
 /**
  * Returns QueryBuilder for products.
  *
  * @param CategoryInterface $category
  *
  * @return QueryBuilder
  */
 protected function getCategoryProductsQueryBuilder(CategoryInterface $category = null)
 {
     $queryBuilder = $this->getRepository()->createQueryBuilder('p')->leftJoin('p.image', 'i')->leftJoin('p.gallery', 'g');
     if ($category) {
         $queryBuilder->leftJoin('p.productCategories', 'pc')->andWhere('pc.category = :categoryId')->setParameter('categoryId', $category->getId());
     }
     return $queryBuilder;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function removeChild(CategoryInterface $childToDelete)
 {
     foreach ($this->getChildren() as $pos => $child) {
         if ($childToDelete->getId() && $child->getId() === $childToDelete->getId()) {
             unset($this->children[$pos]);
             return;
         }
         if (!$childToDelete->getId() && $child === $childToDelete) {
             unset($this->children[$pos]);
             return;
         }
     }
 }
Пример #3
0
 /**
  * Finds $category place in $tree.
  *
  * @param CategoryInterface $category
  * @param array             $tree
  */
 protected function putInTree(CategoryInterface $category, array &$tree)
 {
     if (null === $category->getParent()) {
         $tree[$category->getId()] = $category;
     } else {
         $this->putInTree($category->getParent(), $tree);
     }
 }