Beispiel #1
0
 public function testGetRoutePath()
 {
     $this->assertEquals('', $this->_model->getRoutePath());
     $this->_model->setRoutePath('catalog/product/view/id/50');
     $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath());
     $this->_model->setRoutePath('catalog/product/view');
     $this->_model->setRouteParams(array('id' => 50));
     $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath());
     $this->_model->setRoutePath('adminhtml/system_config/edit');
     $this->_model->setRouteParams(array('section' => 'design', 'key' => '123'));
     $this->assertEquals('admin/system_config/edit/section/design/key/123/', $this->_model->getRoutePath());
 }
Beispiel #2
0
 public function getRoutePath($routeParams = array())
 {
     if ($this->_pageUrlKey === null) {
         if ($this->_query) {
             $this->setData('query_params', $this->_query);
         }
         return parent::getRoutePath($routeParams);
     }
     /* @var $core Mana_Core_Helper_Data */
     $core = Mage::helper('mana_core');
     if (!$this->hasData('route_path')) {
         $query = $this->_query;
         if ($query !== null) {
             if (is_string($query)) {
                 $this->setQuery($query);
             } elseif (is_array($query)) {
                 $this->setQueryParams($query, !empty($routeParams['_current']));
             }
             if ($query === false) {
                 $this->setQueryParams(array());
             }
         }
         $queryParams = $this->getQueryParams();
         $seoParams = array();
         foreach ($this->getQueryParams() as $key => $value) {
             $path = false;
             if ($key == 'p' && $value == 1) {
                 unset($queryParams[$key]);
                 continue;
             }
             if ($value !== null) {
                 if ($url = $this->_getParameterUrl($key)) {
                     $position = $url->getPosition();
                     $attribute_id = $url->getAttributeId();
                     $category_id = null;
                     switch ($url->getType()) {
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_ATTRIBUTE:
                             $path = $this->_generateAttributeParameter($url, $value);
                             break;
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_CATEGORY:
                             list($path, $category_id) = $this->_generateCategoryParameter($url, $value);
                             break;
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_PRICE:
                             $path = $this->_generatePriceParameter($url, $value);
                             break;
                         case Mana_Seo_Model_ParsedUrl::PARAMETER_TOOLBAR:
                             $path = $this->_generateToolbarParameter($url, $value);
                             break;
                         default:
                             throw new Exception('Not implemented');
                     }
                 }
             }
             if ($path) {
                 $seoParams[$key] = compact('path', 'position', 'attribute_id', 'category_id');
                 unset($queryParams[$key]);
             }
         }
         $this->_redirectToSubcategory($seoParams);
         uasort($seoParams, array($this, '_compareSeoParams'));
         $routePath = $this->_encode($this->_pageUrlKey);
         $first = true;
         foreach ($seoParams as $path) {
             if ($first) {
                 if ($routePath) {
                     $routePath .= $this->_schema->getQuerySeparator();
                 }
                 $first = false;
             } else {
                 $routePath .= $this->_schema->getParamSeparator();
             }
             $routePath .= $path['path'];
         }
         if ($routePath) {
             $routePath .= $core->addDotToSuffix($this->_suffix);
         }
         $this->setData('query_params', $queryParams);
         $this->setData('route_path', $routePath);
     }
     return $this->_getData('route_path');
 }
Beispiel #3
0
 public function testGetRoutePath()
 {
     $this->assertEquals('', $this->_model->getRoutePath());
     $this->_model->setRoutePath('catalog/product/view/id/50');
     $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath());
 }
Beispiel #4
0
 /**
  * Retrieve route path
  *
  * @param array $routeParams
  * @return string
  */
 public function getRoutePath($routeParams = array())
 {
     return $this->_helper->getFrontName() . '/' . parent::getRoutePath($routeParams);
 }