/** * Retrieves max price for ranges definition. * * @return float */ public function getMaxPriceInt() { $searchParams = $this->getLayer()->getProductCollection()->getExtendedSearchParams(); $uniquePart = strtoupper(md5(serialize($searchParams))); $cacheKey = 'MAXPRICE_' . $this->getLayer()->getStateKey() . '_' . $uniquePart; $cachedData = Mage::app()->loadCache($cacheKey); if (!$cachedData) { $stats = $this->getLayer()->getProductCollection()->getStats($this->_getFilterField()); $max = $this->_isFacetMaxPriceSet($stats) ? $stats['facets'][$this->_getFilterField()]['max'] : null; if (!is_numeric($max)) { $max = parent::getMaxPriceInt(); } $cachedData = (double) $max; $tags = $this->getLayer()->getStateTags(); $tags[] = self::CACHE_TAG; Mage::app()->saveCache($cachedData, $cacheKey, $tags); } return $cachedData; }
public function testGetMaxPriceInt() { $this->assertEquals(45.0, $this->_model->getMaxPriceInt()); }
/** * Get maximum price from layer products set using cache * * @return float */ public function getMaxPriceInt() { $searchParams = $this->getLayer()->getProductCollection()->getExtendedSearchParams(); $uniquePart = strtoupper(md5(serialize($searchParams . '_' . $this->getCurrencyRate()))); $cacheKey = 'MAXPRICE_' . $this->getLayer()->getStateKey() . '_' . $uniquePart; $cachedData = Mage::app()->loadCache($cacheKey); if (!$cachedData) { $stats = $this->getLayer()->getProductCollection()->getStats($this->_getFilterField()); //This replaces the search I commented out below, and gets the right max price from the db. $max = Mage::getModel('catalog/product')->getCollection()->addFieldToFilter('entity_id', array('in' => $stats['ids']))->addAttributeToSelect('price')->addAttributeToSort('price', 'desc')->getFirstItem()->getPrice(); //$max = $stats[$this->_getFilterField()]['max']; if (!is_numeric($max)) { $max = parent::getMaxPriceInt(); } else { $max = floor($max * $this->getCurrencyRate()); } $cachedData = $max; $tags = $this->getLayer()->getStateTags(); $tags[] = self::CACHE_TAG; Mage::app()->saveCache($cachedData, $cacheKey, $tags); } return $cachedData; }
/** * Get maximum price from layer products set using cache * * @return float */ public function getMaxPriceInt() { $searchParams = $this->getLayer()->getProductCollection()->getExtendedSearchParams(); $spSerialized = serialize($searchParams); $uniquePart = strtoupper(md5(serialize($spSerialized . '_' . $this->getCurrencyRate()))); $cacheKey = 'MAXPRICE_' . $this->getLayer()->getStateKey() . '_' . $uniquePart; $cachedData = Mage::app()->loadCache($cacheKey); if (!$cachedData) { $stats = $this->getLayer()->getProductCollection()->getStats($this->_getFilterField()); $max = $stats[$this->_getFilterField()]['max']; if (!is_numeric($max)) { $max = parent::getMaxPriceInt(); } else { $max = floor($max * $this->getCurrencyRate()); } $cachedData = $max; $tags = $this->getLayer()->getStateTags(); $tags[] = self::CACHE_TAG; Mage::app()->saveCache($cachedData, $cacheKey, $tags); } return $cachedData; }
/** * Get maximum price from layer products set using cache * * @return float */ public function getMaxPriceInt() { $cacheKey = $this->_getUniqueCacheKey('MAXPRICE'); $cachedData = Mage::app()->loadCache($cacheKey); if (!$cachedData) { $stats = $this->getLayer()->getProductCollection()->getStats($this->_getFilterField()); $max = $stats[$this->_getFilterField()]['max']; if (!is_numeric($max)) { $max = parent::getMaxPriceInt(); } else { $max = floor($max * $this->getCurrencyRate()); } $cachedData = $max; $tags = $this->getLayer()->getStateTags(); $tags[] = self::CACHE_TAG; Mage::app()->saveCache($cachedData, $cacheKey, $tags); } return $cachedData; }
/** * Retrieves max price for ranges definition. * * @return float */ public function getMaxPriceInt() { $stats = $this->_getFieldStats(); $max = $stats['max']; if (!is_numeric($max)) { $max = parent::getMaxPriceInt(); } return $max; }
public function getMaxPriceInt() { // for some really UNKNOWN reason magento team // rounds max price to lower value :) return 1 + parent::getMaxPriceInt(); }
/** * For 1.3 ONLY. I LOVE 1.3 :) */ public function getMaxPriceInt() { if (!Mage::helper('amshopby')->isVersionLessThan(1, 4)) { return parent::getMaxPriceInt(); } // I LOVE 1.3 :) $maxPrice = $this->getData('max_price_int'); if (is_null($maxPrice)) { $maxPrice = $this->_getResource()->getMaxValue($this->getAttributeModel(), $this->_getBaseCollectionSql()); $maxPrice = floor($maxPrice); $this->setData('max_price_int', $maxPrice); } return $maxPrice; }