Author: Paweł Jędrzejewski (pawel@sylius.org)
Author: Gonzalo Vilaseca (gvilaseca@reiss.co.uk)
Inheritance: extends Sylius\Bundle\TranslationBundle\Doctrine\ORM\TranslatableResourceRepository
Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = null)
 {
     if (isset($criteria['channels'])) {
         $queryBuilder->innerJoin('o.channels', 'channel')->andWhere('channel = :channel')->setParameter('channel', $criteria['channels']);
         unset($criteria['channels']);
     }
     parent::applyCriteria($queryBuilder, $criteria);
 }
Esempio n. 2
0
 /**
  * Create filter paginator.
  *
  * @param array   $criteria
  * @param array   $sorting
  * @param Boolean $deleted
  *
  * @return PagerfantaInterface
  */
 public function createFilterPaginator($criteria = array(), $sorting = array(), $deleted = false)
 {
     $queryBuilder = parent::getCollectionQueryBuilder()->select('product, variant')->leftJoin('product.variants', 'variant');
     if (!empty($criteria['name'])) {
         $queryBuilder->andWhere('product.name LIKE :name')->setParameter('name', '%' . $criteria['name'] . '%');
     }
     if (!empty($criteria['sku'])) {
         $queryBuilder->andWhere('variant.sku = :sku')->setParameter('sku', $criteria['sku']);
     }
     if (empty($sorting)) {
         if (!is_array($sorting)) {
             $sorting = array();
         }
         $sorting['updatedAt'] = 'desc';
     }
     $this->applySorting($queryBuilder, $sorting);
     if ($deleted) {
         $this->_em->getFilters()->disable('softdeleteable');
     }
     return $this->getPaginator($queryBuilder);
 }
Esempio n. 3
0
 /**
  * @return QueryBuilder
  */
 public function getProductsQueryBuilder()
 {
     return $this->productRepository->getCollectionQueryBuilder();
 }