/** * PriceValues ::= Value {PriceValueSeparator Value } . * @param Mana_Seo_Model_ParsedUrl $token * @return bool */ protected function _parsePriceValues($token) { $cInvalid = Mana_Seo_Model_ParsedUrl::CORRECT_INVALID_PRICE_FILTER_VALUE; $originalToken = $token; if ($pairs = $this->_scanNumbers($token, $this->_schema->getMultipleValueSeparator(), $this->_schema->getPriceSeparator(), '-')) { foreach ($pairs as $pair) { if (!$this->_setPriceFilter($token, $pair['from'], $pair['to'])) { if (!$this->_correct($token, $cInvalid, __LINE__, json_encode($pair))) { return false; } } } } return $this->_parseParameters($originalToken->zoomOut()); }
/** * @param Mana_Seo_Model_Url $parameterUrl * @param string $value * @return string */ protected function _generatePriceParameter($parameterUrl, $value) { /* @var $core Mana_Core_Helper_Data */ $core = Mage::helper('mana_core'); $isSlider = $core->isManadevLayeredNavigationInstalled() && in_array($parameterUrl->getFilterDisplay(), array('slider', 'range', 'min_max_slider')); $path = ''; if ($value == '__0__') { return $parameterUrl->getFinalUrlKey() . $this->_schema->getFirstValueSeparator() . $value; } elseif ($value != '__0__,__1__') { $values = array(); foreach (explode('_', $value) as $singleValue) { $values[] = explode(',', $singleValue); } uasort($values, array($this, '_comparePriceValues')); } else { $values = array(explode(',', $value)); } foreach ($values as $singleValue) { if ($path) { $path .= $this->_schema->getMultipleValueSeparator(); } // prevent a warning when current URL contains incorrect price values like ?price=10 (correct is ?price=10,5) if (!is_array($singleValue) || count($singleValue) < 2) { return false; } list($from, $to) = $singleValue; if ($isSlider) { $path .= $from . $this->_schema->getPriceSeparator() . $to; } else { $index = $from; $range = $to; if ($this->_schema->getUseRangeBounds()) { $from = ($index - 1) * $range; $to = $from + $range; $path .= $from . $this->_schema->getPriceSeparator() . $to; } else { $path .= $index . $this->_schema->getPriceSeparator() . $range; } } } $path = $this->_encode($parameterUrl->getFinalUrlKey()) . $this->_schema->getFirstValueSeparator() . $path; return $path; }