【问题标题】:magento How to rewrite the custom mdoule urlsmagento 如何重写自定义模块 url
【发布时间】:2014-02-19 10:26:51
【问题描述】:

我已经为不同国家和城市的商店创建了自定义模块,所以我必须重写模块的 url 从这个网址http://domain1.com/magento/index.php/shops/index/viewcountry/country/IN/ 到 这个网址 http://domain1.com/magento/index.php/India-sarees-shops.html
下面是我的 urlrewrite 代码

<?php 

        $storeId = Mage::app()->getStore()->getId();
        Mage::getModel('core/url_rewrite')
        ->setIsSystem(0)
        ->setStoreId($storeId)   
        ->setOptions('RP')  
        ->setIdPath('viewcountry/country/' .$country['value'])
        ->setTargetPath($country['label'].'-sarees-shops.html')
        ->setRequestPath('shops/index/viewcountry/country/'.$country['value'].'/')
        ->save(); 
?>

还出现“指定商店的 ID 路径,指定商店的请求路径已存在”错误请帮助我

【问题讨论】:

    标签: magento url-rewriting custom-url


    【解决方案1】:

    试试这个:

    ->setIdPath('viewcountry/country/'.$country['value'].'_'.time())
    

    这会随机化id_path,它仍会从requested_path 重定向到target_path

    【讨论】:

    • 我收到指定商店的错误 ID 路径,指定商店的请求路径已经存在,并且正在重定向工作,但目的地 domain1.com/magento/index.php/India-sarees-shops.html 出现 404 错误,所以请建议我...提前致谢
    • 这意味着您已经使用该请求路径进行了重写。在您的重写管理网格中搜索 shops/index/viewcountry/country/IN 请求路径并将其删除。
    • 是的,我也删除了但收到错误消息。你能建议我用其他方法来重写 magento 中的 url 吗?
    猜你喜欢
    • 2012-08-29
    • 2015-02-28
    • 2016-04-12
    • 1970-01-01
    • 2011-06-13
    • 2018-12-18
    • 2014-07-17
    • 1970-01-01
    • 2015-08-31
    相关资源
    最近更新 更多