简体   繁体   中英

Magento— add to cart— url change

In My site when i click addtocart button it returns the following url:

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

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.

An example:

app/code/local/MyCompany/Ajax/controllers/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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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