Skip to content

Instantly share code, notes, and snippets.

@evgeniy1204
Created April 21, 2018 10:35
Show Gist options
  • Save evgeniy1204/f9030e20971d498b20c82e1001ab866f to your computer and use it in GitHub Desktop.
Save evgeniy1204/f9030e20971d498b20c82e1001ab866f to your computer and use it in GitHub Desktop.
rp
<?php
/**
* Search products with options
*
* @param array $options
*
* @return array
*/
public function searchProducts(array $options = [])
{
$qb = $this->createQueryBuilder('s')
->select('s');
$qb->leftJoin('ProductBundle:ProductVariation', 'productVariation', 'WITH', 'productVariation.product = s.id');
$qb->andWhere('productVariation.isAvailable = 1')
->andWhere('productVariation.amount > 0');
$qb->setMaxResults(10);
dump($qb->getQuery());
dump($qb->getQuery()->getResult());
die;
return $qb->getQuery()->getResult();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment