protected function _getItemsData()
 {
     $data = array();
     $style = Mage::getStoreConfig('layerednav/layerednav/price_style');
     if ('default' == $style) {
         if ($this->getMaxPriceInt()) {
             if ($this->getAttributeModel()->getAttributeCode() == 'price') {
                 try {
                     return parent::_getItemsData();
                 } catch (Zend_Db_No_Exception $e) {
                     return array();
                 }
             } else {
                 return $this->_getDecimalItemsData();
             }
         } else {
             return array();
         }
     } elseif ('input' == $style) {
         list($from, $to) = $this->getFilterValueFromRequest();
         $data[] = array('label' => '', 'value' => $from . ',' . $to, 'count' => 1);
     } elseif ('slider' == $style) {
         $data[] = array('label' => '', 'value' => 0 . ',' . $this->getMaxPriceInt() + 1, 'count' => 1);
     }
     return $data;
 }
Esempio n. 2
0
 /**
  * Get data for build price filter items
  *
  * @return array
  */
 protected function _getItemsData()
 {
     if (!Mage::getStoreConfig('amshopby/general/use_custom_ranges')) {
         return parent::_getItemsData();
     }
     $key = $this->_getCacheKey();
     $data = $this->getLayer()->getAggregator()->getCacheData($key);
     if ($data === null) {
         $ranges = $this->_getCustomRanges();
         $counts = $this->_getResource()->getFromToCount($this, $ranges);
         $data = array();
         foreach ($counts as $index => $count) {
             if (!$index) {
                 // index may be NULL if some products has price out of all ranges
                 continue;
             }
             $from = $ranges[$index][0];
             $to = $ranges[$index][1];
             $data[] = array('label' => $this->_renderFromToItemLabel($from, $to), 'value' => $from . '-' . $to, 'count' => $count, 'pos' => $from);
         }
         usort($data, array($this, '_srt'));
         $tags = array(Mage_Catalog_Model_Product_Type_Price::CACHE_TAG);
         $tags = $this->getLayer()->getStateTags($tags);
         $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
     }
     return $data;
 }
Esempio n. 3
0
 protected function _getItemsData()
 {
     $data = array();
     $style = Mage::getStoreConfig('design/adjnav/price_style');
     if ('default' == $style) {
         if ($this->getMaxPriceInt() || version_compare(Mage::getVersion(), '1.12.0.0', '>=')) {
             if ($this->getAttributeModel()->getAttributeCode() == 'price') {
                 //SOLR COMPATIBILITY .
                 if (Mage::helper('adjnav')->isSolrEnabled()) {
                     if (version_compare(Mage::getVersion(), '1.12.0.0', '<')) {
                         $range = $this->getPriceRange();
                         $facets = $this->getLayer()->getProductCollection()->getFacetedData($this->_getFilterField());
                         if (!empty($facets)) {
                             foreach ($facets as $key => $count) {
                                 preg_match('/TO ([\\d\\.]+)\\]$/', $key, $rangeKey);
                                 $rangeKey = $rangeKey[1] / $range;
                                 if ($count > 0) {
                                     $rangeKey = round($rangeKey);
                                     $data[] = array('label' => $this->_renderItemLabel($range, $rangeKey), 'value' => $rangeKey . ',' . $range, 'count' => $count);
                                 }
                             }
                         }
                     } else {
                         $data = $this->_getItemsData12();
                     }
                 } else {
                     $data = parent::_getItemsData();
                 }
                 //SOLR COMPATIBILITY .
                 if (sizeof($data) == 0 && $this->getInterval()) {
                     //for magento 1.7+/1.12+ to show only one Price filter
                     list($fromPrice, $toPrice) = $this->getInterval();
                     $data[] = array('label' => $this->_renderRangeLabel($fromPrice, $toPrice), 'value' => $fromPrice . $this->_priceDelimeter . $toPrice, 'count' => -1);
                 }
                 //start fix for 28140 bug
                 if (sizeof($data) == 0) {
                     list($from, $to) = $this->getFilterValueFromRequest();
                     $from = sprintf("%u", $from);
                     $to = sprintf("%u", $to);
                     $label = $this->_renderItemLabel($to, $from);
                     $data[] = array('label' => $label, 'value' => $from . $this->_priceDelimeter . $to, 'count' => 0);
                 }
                 //end fix for 28140 bug
                 return $data;
             } elseif ($this->getMaxPriceInt()) {
                 return $this->_getDecimalItemsData();
             }
         } else {
             return array();
         }
     } elseif ('input' == $style) {
         list($from, $to) = $this->getFilterValueFromRequest();
         $data[] = array('label' => '', 'value' => $from . $this->_priceDelimeter . $to, 'count' => 1);
     } elseif ('slider' == $style) {
         $data[] = array('label' => '', 'value' => 0 . $this->_priceDelimeter . $this->getMaxPriceInt() + 1, 'count' => 1);
     }
     return $data;
 }
Esempio n. 4
0
 protected function _getItemsData()
 {
     $data = array();
     $style = Mage::getStoreConfig('multiselectnavigation/general/price_style');
     if ('default' == $style) {
         return parent::_getItemsData();
     } elseif ('input' == $style) {
         list($from, $to) = $this->getFilterValueFromRequest();
         $data[] = array('label' => '', 'value' => $from . ',' . $to, 'count' => 1);
     } elseif ('slider' == $style) {
         $data[] = array('label' => '', 'value' => 0 . ',' . $this->getMaxPriceInt() + 1, 'count' => 1);
     }
     return $data;
 }
Esempio n. 5
0
 protected function _getItemsData()
 {
     $data = array();
     $style = Mage::getStoreConfig('design/adjnav/price_style');
     if ('default' == $style) {
         if ($this->getMaxPriceInt() || version_compare(Mage::getVersion(), '1.7.0.0', '>=')) {
             if ($this->getAttributeModel()->getAttributeCode() == 'price') {
                 if (version_compare(Mage::getVersion(), '1.7.0.0', '>=')) {
                     $data = $this->_getItemsDataParentChanged();
                 } else {
                     if (Mage::helper('adjnav')->getParam($this->_requestVar) && Mage::app()->getRequest()->isXmlHttpRequest()) {
                         list($from, $to) = $this->getFilterValueFromRequest();
                         $from = sprintf("%u", $from);
                         $to = sprintf("%u", $to);
                         $label = $this->_renderItemLabel($to, $from);
                         $data[] = array('label' => $label, 'value' => $from . $this->_priceDelimeter . $to, 'count' => -1);
                     } else {
                         $data = parent::_getItemsData();
                     }
                 }
                 if (sizeof($data) == 0 && $this->getInterval()) {
                     //for magento 1.7+/1.12+ to show only one Price filter
                     list($fromPrice, $toPrice) = $this->getInterval();
                     $data[] = array('label' => $this->_renderRangeLabel($fromPrice, $toPrice), 'value' => $fromPrice . $this->_priceDelimeter . $toPrice, 'count' => -1);
                 }
                 //start fix for 28140 bug
                 if (sizeof($data) == 0) {
                     list($from, $to) = $this->getFilterValueFromRequest();
                     $from = sprintf("%u", $from);
                     $to = sprintf("%u", $to);
                     $label = $this->_renderItemLabel($to, $from);
                     $data[] = array('label' => $label, 'value' => $from . $this->_priceDelimeter . $to, 'count' => 0);
                 }
                 //end fix for 28140 bug
                 return $data;
             } elseif ($this->getMaxPriceInt()) {
                 return $this->_getDecimalItemsData();
             }
         } else {
             return array();
         }
     } elseif ('input' == $style) {
         list($from, $to) = $this->getFilterValueFromRequest();
         $data[] = array('label' => '', 'value' => $from . $this->_priceDelimeter . $to, 'count' => 1);
     } elseif ('slider' == $style) {
         $data[] = array('label' => '', 'value' => 0 . $this->_priceDelimeter . $this->getMaxPriceInt() + 1, 'count' => 1);
     }
     return $data;
 }
Esempio n. 6
0
 /**
  * Get data for build price filter items
  *
  * @return array
  */
 protected function _getItemsData()
 {
     if (!Mage::helper('klevu_search/config')->isExtensionConfigured() || !Mage::helper('klevu_search')->isCatalogSearch()) {
         return parent::_getItemsData();
     }
     $klevu_price_filters = $this->_getKlevuPriceFilters();
     $data = array();
     $k_price = Mage::app()->getRequest()->getParam('price');
     if (!isset($k_price)) {
         if (!empty($klevu_price_filters) && $this->getLayer()->getProductCollection()->count() > 0) {
             foreach ($klevu_price_filters as $filter) {
                 $prices = explode(" - ", $filter['label']);
                 $fromPrice = $prices[0];
                 $toPrice = $prices[1];
                 $data[] = array('label' => $this->_renderRangeLabel($fromPrice, $toPrice), 'value' => $fromPrice . '-' . $toPrice, 'count' => $filter['count']);
             }
         }
     }
     return $data;
 }
 protected function _getItemsData()
 {
     if ($this->usePriceRanges()) {
         $data = array();
         if ($this->getInterval()) {
             return $data;
         }
         $priceRanges = $this->_getPriceRanges();
         $priceRanges = explode(';', $priceRanges);
         foreach ($priceRanges as $priceRange) {
             $range = explode('-', $priceRange);
             $min = (int) $range[0];
             $max = (int) $range[1];
             if (0 === $min) {
                 // from 0 to x
                 $counts = $this->getRangeItemCounts($max);
                 $count = 0;
                 if (array_key_exists(1, $counts)) {
                     $count = $counts[1];
                 }
             } elseif (0 === $max) {
                 // from x to infinite
                 $counts = $this->getRangeItemCounts($min);
                 if (array_key_exists(1, $counts)) {
                     unset($counts[1]);
                 }
                 $count = array_sum($counts);
             } else {
                 // from x to y
                 $range = array($min, $max);
                 $min = min($range);
                 $max = max($range);
                 if (extension_loaded('gmp') && function_exists('gmp_gcd')) {
                     $gcd = gmp_intval(gmp_gcd($min, $max));
                 } else {
                     $gcd = gcd($min, $max);
                 }
                 $counts = $this->getRangeItemCounts($gcd);
                 $count = 0;
                 for ($i = (int) ($min / $gcd) + 1; $i * $gcd <= $max; $i++) {
                     if (array_key_exists($i, $counts)) {
                         $count += $counts[$i];
                     }
                 }
             }
             if (0 < $count) {
                 $range = explode('-', $priceRange);
                 $data[] = array('label' => $this->_renderRangeLabel($range[0], $range[1]), 'value' => $priceRange, 'count' => $count);
             }
         }
         return $data;
     }
     return parent::_getItemsData();
 }