Exemple #1
0
 /**
  * Absolute url by key
  *
  * @param string     $basePath
  * @param string     $urlKey
  * @param bool|false $params
  * @return string
  */
 protected function getUrlByKey($basePath, $urlKey, $params = false)
 {
     if ($urlKey) {
         $url = $basePath . '/' . $urlKey;
     } else {
         $url = $basePath;
     }
     $configUrlSuffix = $this->scopeConfig->getValue('catalog/seo/product_url_suffix');
     //user can enter .html or html suffix
     if ($configUrlSuffix != '' && $configUrlSuffix[0] != '.') {
         $configUrlSuffix = '.' . $configUrlSuffix;
     }
     if (substr($url, -strlen($configUrlSuffix)) == $configUrlSuffix) {
         $url = substr($url, 0, -strlen($configUrlSuffix));
     }
     $url .= $configUrlSuffix;
     if ($params) {
         $url .= '?' . http_build_query($params);
     }
     $url = $this->urlManager->getDirectUrl($url);
     return $url;
 }
Exemple #2
0
 /**
  * Note: isolation flushes the URL memory cache
  * @magentoAppIsolation enabled
  */
 public function testGetDirectUrl()
 {
     $directUrl = $this->_model->getDirectUrl('fancy_uri', array('_query' => array('foo' => 'bar')));
     $this->assertEquals('http://localhost/index.php/fancy_uri?foo=bar', $directUrl);
 }