Beispiel #1
0
 public function testConfigValues()
 {
     $map = $this->getValueMap();
     $this->scopeConfig->expects($this->exactly(5))->method('getValue')->will($this->returnCallback(function ($key, $scope) use($map) {
         $this->assertArrayHasKey($key, $map);
         return $map[$key]['scope'] === $scope ? $map[$key]['value'] : null;
     }));
     $this->assertSame($map[Price::XML_PATH_RANGE_CALCULATION]['value'], $this->target->getRangeCalculationValue());
     $this->assertSame($map[Price::XML_PATH_RANGE_STEP]['value'], $this->target->getRangeStepValue());
     $this->assertSame($map[Price::XML_PATH_ONE_PRICE_INTERVAL]['value'], $this->target->getOnePriceIntervalValue());
     $this->assertSame($map[Price::XML_PATH_INTERVAL_DIVISION_LIMIT]['value'], $this->target->getIntervalDivisionLimitValue());
     $this->assertSame($map[Price::XML_PATH_RANGE_MAX_INTERVALS]['value'], $this->target->getRangeMaxIntervalsValue());
 }
Beispiel #2
0
 /**
  * {@inheritDoc}
  */
 public function addFacetToCollection($config = [])
 {
     $facetField = $this->getFilterField();
     $facetType = BucketInterface::TYPE_HISTOGRAM;
     $customerGroupId = $this->customerSession->getCustomerGroupId();
     $facetConfig = ['nestedFilter' => ['price.customer_group_id' => $customerGroupId], 'minDocCount' => 1];
     $calculation = $this->dataProvider->getRangeCalculationValue();
     if ($calculation === \Magento\Catalog\Model\Layer\Filter\DataProvider\Price::RANGE_CALCULATION_MANUAL) {
         if ((int) $this->dataProvider->getRangeStepValue() > 0) {
             $facetConfig['interval'] = (int) $this->dataProvider->getRangeStepValue();
         }
     }
     $productCollection = $this->getLayer()->getProductCollection();
     $productCollection->addFacet($facetField, $facetType, $facetConfig);
     return $this;
 }