/** * Process url rewrite * * @param array $rewriteInfo * @param Enterprise_UrlRewrite_Model_Url_Rewrite_Request $rewriteRequest * @param Enterprise_UrlRewrite_Model_Url_Rewrite $rewrite * @param array $matchers * @param Mage_Core_Model_Resource $resource * @return bool */ function processRewrite($rewriteInfo, $rewriteRequest, $rewrite, $matchers, $resource) { $result = false; Mage::app()->setCurrentStore(Mage::app()->getStore($rewriteInfo['store_id'])); $requestPath = $rewriteInfo['request_path']; $paths = $rewriteRequest->getSystemPaths($requestPath); $rewriteRows = $rewrite->getResource()->getRewrites($paths); foreach ($matchers as $matcherIndex) { $matcher = Mage::getModel(Mage::getConfig()->getNode(sprintf(Enterprise_UrlRewrite_Model_Url_Rewrite::REWRITE_MATCHERS_MODEL_PATH, $matcherIndex), 'default')); foreach ($rewriteRows as $row) { if ($matcher->match($row, $paths['request'])) { switch ($row['entity_type']) { case Enterprise_Catalog_Model_Product::URL_REWRITE_ENTITY_TYPE: $targetProductId = $this->getProductId($resource, $row); if ($targetProductId != $rewriteInfo['product_id']) { $targetProduct = Mage::getModel('catalog/product')->setStoreId($rewriteInfo['store_id'])->load($targetProductId); $this->processProduct($targetProduct, $targetProduct->getUrlKey(), $targetProduct->getStoreId()); $result = true; } break; case Enterprise_Catalog_Model_Category::URL_REWRITE_ENTITY_TYPE: $categoryId = $this->getCategoryId($resource, $row); if ($categoryId != $rewriteInfo['category_id']) { $category = Mage::getModel('catalog/category', array('disable_flat' => true))->setStoreId($rewriteInfo['store_id'])->load($categoryId); $this->processCategory($category, $category->getUrlKey(), $category->getStoreId()); $result = true; } break; } } } } return $result; }