/** * Get product rewrite path in new store * * @param array $redirect * @param int $categoryId * @return string */ protected function _getProductRequestPath($redirect, $categoryId) { $requestPath = ''; $rewrite = $this->_productResource->getRewriteByProductId($redirect['product_id'], $this->_storeId); if ($rewrite) { $requestPath = $rewrite['request_path']; if (!empty($this->_newProductStoreSeoSuffix)) { $requestPath .= '.' . $this->_newProductStoreSeoSuffix; } if (!empty($categoryId)) { $requestPath = $this->_getNewStoreCategoryPath($categoryId) . '/' . $requestPath; } $requestPath = $this->_getBaseUrl() . $requestPath; } return $requestPath; }
/** * Redirect to product from another store if custom url key defined * * @param int $productId * @param string $categoryPath */ protected function _checkStoreRedirect($productId, $categoryPath) { if ($this->_prevStoreId != $this->_storeId) { $rewrite = $this->_productResource->getRewriteByProductId($productId, $this->_storeId); if (!empty($rewrite)) { $requestPath = $rewrite['request_path']; if (!empty($this->_newStoreSeoSuffix)) { $requestPath .= '.' . $this->_newStoreSeoSuffix; } if (!empty($categoryPath)) { $requestPath = $this->_getNewStoreCategoryPath($categoryPath) . '/' . $requestPath; } $requestPath = $this->_getBaseUrl() . $requestPath; $this->_response->setRedirect($requestPath, 301); $this->_request->setDispatched(true); } } }