简体   繁体   English

Magento-添加到cart-url更改

[英]Magento— add to cart— url change

In My site when i click addtocart button it returns the following url: 在我的网站中,当我点击addtocart按钮时,它返回以下网址:

http://mywebsite.com/ajax/index/add/uenc/a...cC5uZXQvYXBwbGlhbmNlcy5odG1s/product/83/isAjax/1 http://mywebsite.com/ajax/index/add/uenc/a...cC5uZXQvYXBwbGlhbmNlcy5odG1s/product/83/isAjax/1

But i need the specific url which is below: 但我需要下面的具体网址:

http://mywebsite.com/checkout/cart/add/uenc/a...cC5uZXQvYXBwbGlhbmNlcy5odG1s/product/83/isAjax/1 http://mywebsite.com/checkout/cart/add/uenc/a...cC5uZXQvYXBwbGlhbmNlcy5odG1s/product/83/isAjax/1

can i know where to edit this? 我可以知道在哪里编辑吗?

Of course you can change it in all your theme files. 当然,您可以在所有主题文件中更改它。

However, if you want to change all add to cart behavior site wide you may want to extend the CartController and forward the add action to your own ajax module. 但是,如果要更改站点范围内的所有添加到购物车行为,您可能需要扩展CartController并将添加操作转发到您自己的ajax模块。

An example: 一个例子:

app/code/local/MyCompany/Ajax/controllers/CartController.php: 应用程序/代码/本地/ MyCompany的/ AJAX /控制器/ CartController.php:

<?php

require_once 'Mage/Checkout/controllers/CartController.php';
class MyCompany_Ajax_CartController extends Mage_Checkout_CartController {

    public function addAction() {
        $this->_forward('add', 'index', 'ajax', $this->getRequest()->getParams());
    }

}

app/code/local/MyCompany/Ajax/etc/config.xml: 应用程序/代码/本地/ MyCompany的/阿贾克斯的/ etc / config.xml文件:

<?xml version="1.0"?>
<config>

    [...]

     <frontend>
           <routers>
                <checkout>
                    <args>
                        <modules>
                            <mycompany_ajax before="Mage_Checkout">MyCompany_Ajax</mycompany_ajax>
                        </modules>
                    </args>
                </checkout>
            </routers>
        </frontend>
    </config>

Another way is to add an observer that listens to the controller_action_predispatch_checkout_cart_add event and forward there. 另一种方法是添加一个侦听controller_action_predispatch_checkout_cart_add事件并在那里转发的观察者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM