/** * Implement logic of custom rewrites * * @return bool */ protected function _rewriteDb() { if (null === $this->_rewrite->getStoreId() || false === $this->_rewrite->getStoreId()) { $this->_rewrite->setStoreId($this->_app->getStore()->getId()); } $requestCases = $this->_getRequestCases(); $this->_rewrite->loadByRequestPath($requestCases); $fromStore = $this->_request->getQuery('___from_store'); if (!$this->_rewrite->getId() && $fromStore) { $stores = $this->_app->getStores(false, true); if (!empty($stores[$fromStore])) { /** @var $store Mage_Core_Model_Store */ $store = $stores[$fromStore]; $fromStoreId = $store->getId(); } else { return false; } $this->_rewrite->setStoreId($fromStoreId)->loadByRequestPath($requestCases); if (!$this->_rewrite->getId()) { return false; } // Load rewrite by id_path $currentStore = $this->_app->getStore(); $this->_rewrite->setStoreId($currentStore->getId())->loadByIdPath($this->_rewrite->getIdPath()); $this->_setStoreCodeCookie($currentStore->getCode()); $targetUrl = $currentStore->getBaseUrl() . $this->_rewrite->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); } if (!$this->_rewrite->getId()) { return false; } $this->_request->setAlias(Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $this->_rewrite->getRequestPath()); $this->_processRedirectOptions(); return true; }
public function testCRUD() { $this->_model->setStoreId(Mage::app()->getDefaultStoreView()->getId())->setRequestPath('fancy/url.html')->setTargetPath('catalog/product/view')->setIsSystem(1)->setOptions('RP'); $crud = new Magento_Test_Entity($this->_model, array('request_path' => 'fancy/url2.html')); $crud->testCrud(); }
* If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento * @package Mage_Catalog * @subpackage integration_tests * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Extends valid Url rewrites */ require __DIR__ . '/url_rewrites.php'; /** * Invalid rewrite for product assigned to different category */ $rewrite = new Mage_Core_Model_Url_Rewrite(); $rewrite->setStoreId(1)->setIdPath('product/1/4')->setRequestPath('category-2/simple-product.html')->setTargetPath('catalog/product/view/id/1')->setIsSystem(1)->setCategoryId(4)->setProductId(1)->save(); /** * Invalid rewrite for product assigned to category that doesn't belong to store */ $rewrite = new Mage_Core_Model_Url_Rewrite(); $rewrite->setStoreId(1)->setIdPath('product/1/5')->setRequestPath('category-5/simple-product.html')->setTargetPath('catalog/product/view/id/1')->setIsSystem(1)->setCategoryId(5)->setProductId(1)->save();