示例#1
0
 /**
  * Process redirect (R) and permanent redirect (RP)
  *
  * @return Mage_Core_Model_Url_Rewrite_Request
  */
 protected function _processRedirectOptions()
 {
     $isPermanentRedirectOption = $this->_rewrite->hasOption('RP');
     $external = substr($this->_rewrite->getTargetPath(), 0, 6);
     if ($external === 'http:/' || $external === 'https:') {
         $destinationStoreCode = $this->_app->getStore($this->_rewrite->getStoreId())->getCode();
         $this->_setStoreCodeCookie($destinationStoreCode);
         $this->_sendRedirectHeaders($this->_rewrite->getTargetPath(), $isPermanentRedirectOption);
     }
     $targetUrl = $this->_request->getBaseUrl() . '/' . $this->_rewrite->getTargetPath();
     $storeCode = $this->_app->getStore()->getCode();
     if (Mage::getStoreConfig('web/url/use_store') && !empty($storeCode)) {
         $targetUrl = $this->_request->getBaseUrl() . '/' . $storeCode . '/' . $this->_rewrite->getTargetPath();
     }
     if ($this->_rewrite->hasOption('R') || $isPermanentRedirectOption) {
         $this->_sendRedirectHeaders($targetUrl, $isPermanentRedirectOption);
     }
     $queryString = $this->_getQueryString();
     if ($queryString) {
         $targetUrl .= '?' . $queryString;
     }
     $this->_request->setRequestUri($targetUrl);
     $this->_request->setPathInfo($this->_rewrite->getTargetPath());
     return $this;
 }
示例#2
0
 public function testLoadByIdPath()
 {
     $this->_model->setStoreId(Mage::app()->getDefaultStoreView()->getId())->setRequestPath('product1.html')->setTargetPath('catalog/product/view/id/1')->setIdPath('product/1')->setIsSystem(1)->setOptions('RP')->save();
     try {
         $read = Mage::getModel('Mage_Core_Model_Url_Rewrite');
         $read->setStoreId(Mage::app()->getDefaultStoreView()->getId())->loadByIdPath('product/1');
         $this->assertEquals($this->_model->getStoreId(), $read->getStoreId());
         $this->assertEquals($this->_model->getRequestPath(), $read->getRequestPath());
         $this->assertEquals($this->_model->getTargetPath(), $read->getTargetPath());
         $this->assertEquals($this->_model->getIdPath(), $read->getIdPath());
         $this->assertEquals($this->_model->getIsSystem(), $read->getIsSystem());
         $this->assertEquals($this->_model->getOptions(), $read->getOptions());
         $this->_model->delete();
     } catch (Exception $e) {
         $this->_model->delete();
         throw $e;
     }
 }