/**
  * This returns the first variant, which matches exactly the given facet group set
  *
  * @param FacetGroupSet $facetGroupSet
  *
  * @return Variant|null
  */
 public function getVariantByFacets(FacetGroupSet $facetGroupSet)
 {
     $key = $facetGroupSet->getUniqueKey();
     foreach ($this->variants as $variant) {
         if ($variant->getFacetGroupSet()->getUniqueKey() === $key) {
             return $variant;
         }
     }
     return null;
 }
 public function testHasGroup()
 {
     $facetGroupSet = new FacetGroupSet(array(4 => array(3, 2)));
     $this->assertTrue($facetGroupSet->hasGroup(4));
     $this->assertFalse($facetGroupSet->hasGroup(3));
 }
 /**
  * @param FacetManagerInterface $facetManager
  */
 public function setFacetManager(FacetManagerInterface $facetManager)
 {
     $this->facetManager = $facetManager;
     Model\FacetGroupSet::setFacetManager($facetManager);
 }
 /**
  * @depends testFromJson
  */
 public function testGetGender(Variant $variant)
 {
     $facetManager = $this->getFacetManager('facets-all.json');
     FacetGroupSet::setFacetManager($facetManager);
     $facetGroup = $variant->getGender();
     $this->assertInstanceOf('\\AboutYou\\SDK\\Model\\FacetGroup', $facetGroup);
     $this->assertEquals('genderage', $facetGroup->getName());
     $this->assertEquals('Unisex', $facetGroup->getFacetNames());
     $facet = $facetManager->getFacet(3, 64);
     $this->assertInstanceOf('\\AboutYou\\SDK\\Model\\Facet', $facet);
     $this->assertEquals('unisex', $facet->getValue());
     $this->assertEquals('Unisex', $facet->getName());
     $this->assertEquals('genderage', $facet->getGroupName());
 }
 private function containsFacetGroupSet(FacetGroupSet $facetGroupSet)
 {
     if ($this->getUniqueKey() === $facetGroupSet->getUniqueKey()) {
         return true;
     }
     $myLazyGroups = $this->getLazyGroups();
     foreach ($facetGroupSet->getLazyGroups() as $id => $group) {
         if (!isset($myLazyGroups[$id]) || $myLazyGroups[$id]->getUniqueKey() !== $group->getUniqueKey()) {
             return false;
         }
     }
     return true;
 }
 /**
  * @param FacetGroupSet $facetGroupSet
  * @param boolean $append, if true the category ids will added to current filter
  *
  * @return ProductSearchCriteria
  */
 public function filterByFacetGroupSet(FacetGroupSet $facetGroupSet, $append = false)
 {
     return $this->filterByFacetIds($facetGroupSet->getIds(), $append);
 }