Example #1
0
 public function testGetUrl()
 {
     $product = new Mage_Catalog_Model_Product();
     $product->load(1);
     $this->assertStringEndsWith('simple-product.html', $this->_model->getUrl($product));
     $product = new Mage_Catalog_Model_Product();
     $product->setId(100);
     $this->assertStringEndsWith('catalog/product/view/id/100/', $this->_model->getUrl($product));
 }
Example #2
0
 /**
  * Retrieve URL Rewrite Instance
  *
  * @return Mage_Core_Model_Url_Rewrite
  */
 public function getUrlRewrite()
 {
     if (!self::$_urlRewrite) {
         self::$_urlRewrite = Mage::getModel('Mage_Core_Model_Url_Rewrite');
     }
     return self::$_urlRewrite;
 }
 public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
 {
     if (Mage::getVersion() >= 1.8) {
         $product->setData('url', '');
     }
     return parent::getUrl($product, $params);
 }
Example #4
0
 /**
  * @return Mage_Core_Model_Url_Rewrite
  */
 public function getUrlRewrite()
 {
     if (!self::$_urlRewrite) {
         self::$_urlRewrite = Mage::getModel('core/url_rewrite');
     }
     return self::$_urlRewrite;
 }
Example #5
0
 /**
  * Retrieve Product URL using UrlDataObject
  *
  * @param Mage_Catalog_Model_Product $product
  * @param array $params
  * @return string
  */
 public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
 {
     if (!Mage::helper('ascurl')->useCanonicalUrl()) {
         return parent::getUrl($product, $params);
     }
     $routePath = '';
     $routeParams = $params;
     $storeId = $product->getStoreId();
     if (isset($params['_ignore_category'])) {
         unset($params['_ignore_category']);
         $categoryId = null;
     } else {
         $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : null;
     }
     if (!$categoryId) {
         $product = Mage::getModel('catalog/product')->load($product->getId());
         $categoryId = Mage::helper('ascurl')->getCategoryIdAsc($product);
     }
     if ($product->hasUrlDataObject()) {
         $requestPath = $product->getUrlDataObject()->getUrlRewrite();
         $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
     } else {
         $requestPath = $product->getRequestPath();
         if (empty($requestPath)) {
             $idPath = sprintf('product/%d', $product->getEntityId());
             if ($categoryId) {
                 $idPath = sprintf('%s/%d', $idPath, $categoryId);
             }
             $rewrite = $this->getUrlRewrite();
             $rewrite->setStoreId($storeId)->loadByIdPath($idPath);
             if ($rewrite->getId()) {
                 $requestPath = $rewrite->getRequestPath();
                 $product->setRequestPath($requestPath);
             }
         }
     }
     if (isset($routeParams['_store'])) {
         $storeId = Mage::app()->getStore($routeParams['_store'])->getId();
     }
     if ($storeId != Mage::app()->getStore()->getId()) {
         $routeParams['_store_to_url'] = true;
     }
     if (!empty($requestPath)) {
         $routeParams['_direct'] = $requestPath;
     } else {
         $routePath = 'catalog/product/view';
         $routeParams['id'] = $product->getId();
         $routeParams['s'] = $product->getUrlKey();
         if ($categoryId) {
             $routeParams['category'] = $categoryId;
         }
     }
     // reset cached URL instance GET query params
     if (!isset($routeParams['_query'])) {
         $routeParams['_query'] = array();
     }
     return $this->getUrlInstance()->setStore($storeId)->getUrl($routePath, $routeParams);
 }
Example #6
0
 public function testGetUrl()
 {
     /** @var $product Mage_Catalog_Model_Product */
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     $product->load(1);
     $this->assertStringEndsWith('simple-product.html', $this->_model->getUrl($product));
     $product = Mage::getModel('Mage_Catalog_Model_Product');
     $product->setId(100);
     $this->assertStringEndsWith('catalog/product/view/id/100/', $this->_model->getUrl($product));
 }
Example #7
0
 /**
  * Get product url
  *
  * @param  Mage_Catalog_Model_Product $product
  * @param bool $useSid
  * @return string
  */
 public function getProductUrl($product, $useSid = true)
 {
     if (!Mage::getSingleton('Flagbit_Typo3connect/Core')->isEnabled()) {
         return parent::getProductUrl($product, $useSid);
     }
     $queryParams = '';
     Varien_Profiler::start('REGULAR: ' . __METHOD__);
     $url = $this->getUrlInstance()->getUrl('catalog/product/view', array('id' => $product->getId(), 's' => $product->getUrlKey(), 'category' => $product->getCategoryId())) . $queryParams;
     Varien_Profiler::stop('REGULAR: ' . __METHOD__);
     return $url;
 }
Example #8
0
 public function getProductUrl($product, $useSid = null)
 {
     $url = null;
     if ($useSid == 'mw_false') {
         return parent::getProductUrl($product, false);
     }
     //$url = Mage::helper('seosuite')->getCanonicalUrl($product);
     if (!$url) {
         $url = parent::getProductUrl($product, $useSid);
     }
     return $url;
 }
 /**
  * Retrieve Product Url Path (include category)
  *
  * @param Mage_Catalog_Model_Category $category
  * @return string
  */
 public function getUrlPath($category = null)
 {
     return $this->_urlModel->getUrlPath($this, $category);
 }
Example #10
0
 /**
  * @param Mage_Catalog_Model_Product $product
  * @param array $params
  * @return int|null
  */
 protected function _getCategoryIdForUrl($product, $params)
 {
     if (!$this->_store->getConfig(Mage_Catalog_Helper_Product::XML_PATH_PRODUCT_URL_USE_CATEGORY)) {
         return null;
     }
     return parent::_getCategoryIdForUrl($product, $params);
 }