Magento购物篮页面的自定义URL [英] Custom URL for Magento's basket page

查看:98
本文介绍了Magento购物篮页面的自定义URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为Magento的购物篮实施自定义URL. Magento开箱即用的网址是/checkout/cart,但客户要求/checkout/bag.

I'd like to implement custom URL for our Magento's basket. Magento out-of-the-box url paht is /checkout/cart but client request /checkout/bag.

我试图以某种方式 *后端中的URL重写管理-可以,但是我需要将代码中的所有匹配项更新为新的url,因为$ this-> getUrl('checkout/cart')不会转换为checkout/bag *我也尝试遵循 http://alanstorm.com/magento_dispatch_rewrites_intro 的一些建议,但从根本上讲,它也对我没有帮助. *我也尝试过这篇文章中的示例 http://phprelated.myworks.ro/two-add-to-cart-buttons-with-different-redirect-actions-at-once-in-magnto/

I tried to somehow * URL rewrite management in backend - it works, but I need to update all occurences in code to new url, because $this->getUrl('checkout/cart') doesnt translate into checkout/bag * also I tried to follow some advices from http://alanstorm.com/magento_dispatch_rewrites_intro but basicaly it doesnt help me too. * also I tried example from this post http://phprelated.myworks.ro/two-add-to-cart-buttons-with-different-redirect-actions-at-once-in-magnto/

所以,有什么方法可以在不更新模板和类$ this-> getUrl('checkout/cart')中所有出现的情况下,将路径'checkout/cart'转换为checkout/bag

So, is there any way how can I rewrite translation from path 'checkout/cart' into checkout/bag without updating all ocurrences in our templates and classes $this->getUrl('checkout/cart')

任何依赖于Web服务器体系结构的解决方案都不是最终解决方案.

Any solution depending on web server architecture are not the ultimate solution.

推荐答案

我找到了解决方法

1)我重写了模型core/url以具有所需的输出

1) I rewrited model core/url to have desired output

编辑1 -示例实现 https://gist.github.com/jaromirmuller/132cdd9378e5b1018170

2)在config.xml中添加了URL重写,该重写将URL路径从/checkout/bag重写到/checkout/cart

2) Added url rewrite into config.xml which rewrites url path from /checkout/bag to /checkout/cart

    <global>
      <rewrite>
        <mynamespace_mymodule_checkout_cart>
            <from><![CDATA[#^/checkout/bag#]]></from>
            <to>/checkout/cart</to>
        </mynamespace_mymodule_checkout_cart>
         </rewrite>
    </global>

3)将url重写添加到目录> URL重写管理中,该管理处理是否有人进入/checkout/cart然后将他重定向到正确的/checkout/bag paht.

3) Added url rewrite into Catalog > URL rewrite management which handles if anyone comes to /checkout/cart then he's redirected to /checkout/bag paht which is correct.

这3点使站点保持一致并且可以正常工作.这是无需重写大量模板和类的简便方法.

These 3 points makes site consisten and working without any issues. That's the easises way without rewriting tons of templates and classes.

这篇关于Magento购物篮页面的自定义URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆