Created
July 10, 2014 14:42
-
-
Save ArFeRR/cebb2bf54232069d817b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$finder = $this->container->get('fos_elastica.finder.ooo.product'); | |
$option1 = new \Elastica\Filter\Term(); | |
$option1->setTerm('productsOptionValues.productOption', 'resolution'); | |
$value1 = new \Elastica\Filter\Term(); | |
$value1->setTerm('productsOptionValues.value', '1920x1080'); | |
$andResolution1 = new \Elastica\Filter\BoolAnd(); | |
$andResolution1->addFilter($option1); | |
$andResolution1->addFilter($value1); | |
$value2 = new \Elastica\Filter\Term(); | |
$value2->setTerm('productsOptionValues.value', '1600x900'); | |
$andResolution2 = new \Elastica\Filter\BoolAnd(); | |
$andResolution2->addFilter($option1); | |
$andResolution2->addFilter($value2); | |
$option2 = new \Elastica\Filter\Term(); | |
$option2->setTerm('productsOptionValues.productOption', 'weight'); | |
$value1 = new \Elastica\Filter\Term(); | |
$value1->setTerm('productsOptionValues.value', '2,9 kg'); | |
$andWeightInner = new \Elastica\Filter\BoolAnd(); | |
$andWeightInner->addFilter($option2); | |
$andWeightInner->addFilter($value1); | |
$orResolution = new \Elastica\Filter\BoolOr(); | |
$orResolution->addFilter($andResolution1); | |
$orResolution->addFilter($andResolution2); | |
$andWeightOuter = new \Elastica\Filter\BoolAnd(); | |
$andWeightOuter->addFilter($orResolution); | |
$andWeightOuter->addFilter($andWeightInner); | |
$nested = new \Elastica\Filter\Nested(); | |
$nested->setPath("productsOptionValues"); | |
$nested->setFilter($andWeightOuter); | |
$filtered = new \Elastica\Query\Filtered(); | |
$filtered->setFilter($nested); | |
$results = $finder->find($filtered); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment