Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Seo 如何强制magento使用完整的产品路径?_Seo_Magento_Url Rewriting_Path - Fatal编程技术网

Seo 如何强制magento使用完整的产品路径?

Seo 如何强制magento使用完整的产品路径?,seo,magento,url-rewriting,path,Seo,Magento,Url Rewriting,Path,我对magento产品链接有问题。当我搜索一个产品,然后单击产品链接时,Magento将我重定向到index.php/test666.html,而它应该是index.php/products/screery/miso-soup/test666.html 是否可以强制Magento使用产品的完整路径 增加: 我无法通过启用“为产品URL使用类别路径”使其工作。因此,我最终得到了以下代码 $categories = $_product->getCategoryIds(); $lastCateg

我对magento产品链接有问题。当我搜索一个产品,然后单击产品链接时,Magento将我重定向到index.php/test666.html,而它应该是index.php/products/screery/miso-soup/test666.html

是否可以强制Magento使用产品的完整路径

增加:

我无法通过启用“为产品URL使用类别路径”使其工作。因此,我最终得到了以下代码

$categories = $_product->getCategoryIds();
$lastCategory = $_categoryModel->load(end($categories));

$urlPath = explode("/",$lastCategory->getUrlPath());

$urlPathCnt = count($urlPath)-1;
$urlPath[$urlPathCnt] = str_replace(".html","",$urlPath[$urlPathCnt]);
$productUrl = "/".implode("/",$urlPath)."/".$_product->getUrlKey().".html";

但我真的不喜欢这样。它使用了不必要的资源。有什么想法吗?

在管理中,转到
系统>配置>目录>搜索引擎优化
并为产品URL设置
使用类别路径
您可能需要刷新“目录URL重写”索引。HTML也可以从缓存中提供,因此刷新不会有任何伤害。

还要确保使用方法
$product->getProductUrl()
利用上述设置。

搜索结果不会提供完整链接,因为Magento允许任何产品处于多个类别中。如果使用搜索框,则无法猜测产品的正确类别。换句话说,一个产品链接可以有多个URL


如果您完全确定每个产品只分配一个类别,则可以更改搜索源代码或进行扩展,以显示每个搜索结果的完整路径链接。

我假设搜索结果不会提供完整链接,因为Magento允许任何产品处于多个类别中。如果使用搜索框,则无法猜测产品的正确类别。换句话说,一个产品链接可以有多个URL


但如果您完全确定每个产品只分配一个类别,则可以更改搜索源代码或进行扩展,以显示每个搜索结果的完整路径链接

我写了一个函数来实现这个-@Moon,在这里我必须粘贴这个代码..因为我是magento的新手,谢谢:)