Custom URL for Magento's basket page

霸气de小男生 提交于 2019-12-06 15:16:16

问题


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.

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/

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')

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


回答1:


I found solution

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

EDIT 1 - sample implementation https://gist.github.com/jaromirmuller/132cdd9378e5b1018170

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) 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.

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




回答2:


The way Url Rewrites work means that you have some url test.com/some on the page and when you click on it, you'll get test.com/some2 instead. So Rewrites do not change the actual anchor link - they change the destination of that link to the new recipient.

There is no easy solution which will change all of the anchor links to the new ones (aside from parsing and replacing links on each page - which is not preferable).

So if you want to leave anchor links as they are and get the new Url after user clicks on the link, you should go with Url Rewrites. Though if you want to change the actual links on the page, you need to search for all occurrences and change them manually.

Mage::getUrl() is not a fabric which operates with aliases (like Mage::getModel()) - you'll get from it what you have inserted, and the only way to change the outcome Url is to change income parameters.




回答3:


You can do it using apache url rewrites. Something like

RewriteRule ^/checkout/cart(.*)$ /checkout/bag$1 [R=301,NC,L]



回答4:


This answer works for changing the wishlist name by changing the frontend routers in app/etc/local.xml. Maybe it can be adapted for your uses?

Change wishlist url in magento




回答5:


To manage more url translation You can use this module: http://www.magentocommerce.com/magento-connect/catalog/product/view/id/18160/



来源:https://stackoverflow.com/questions/12722841/custom-url-for-magentos-basket-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!