从购物车中删除商品时,Magento 重定向到商店主页而不是 /checkout/cart/

发布于 2024-10-20 11:52:16 字数 968 浏览 2 评论 0原文

我正在设置 Magento 1.4.2 购物车来替换旧版本 (1.1.6)。我目前正在开发机器上工作,当我的购物车中有多个商品并使用其中一个产品上的“删除”按钮时,该商品将被删除,并且我会通过 302 响应代码重定向到该产品的基本 URL商店,而不是“/checkout/cart/”(这是旧版本购物车的工作方式)。

我一直在试图找出导致此重定向的两个购物车之间的不同之处。关于我的设置的一些注释可能相关,也可能不相关

我正在寻找任何关于在哪里查看的提示 - 通过管理面板进行 Magento 配置、local.xml 更改、Apache 重写规则...有关如何找出为什么这个新购物车没有重定向到 / 的任何提示store/checkout/cart/ 当我从购物车中删除产品时

如果您需要更多详细信息,我很乐意提供。我们有一个真正被整合在一起的有点时髦的设置,如果听起来我们做错了什么,我也愿意接受关于如何设置的建议。谢谢!

I'm setting up a Magento 1.4.2 cart to replace an older version (1.1.6). I'm currently working on a development machine, and when I have multiple items in my cart and use the "delete" button on one of the products the item is removed and I am redirected via a 302 response code to the base URL of the store, instead of to '/checkout/cart/' (which is how the older version cart works).

I'm stuck trying to figure out what is different between the two carts that is causing this redirect. Some notes on my setup that may or may not be relevant:

  • There are 2 websites/stores/store views
  • The store view I'm currently working with is accessed via a sub-URL and separate index.php file. The main store URL is https://www.thestore.com/ and the store I'm working with is accessed at https://www.thestore.com/second-store/index.php/. If you're unfamiliar with this approach, here is how it is done: Store views by index.php
  • The old cart (running 1.1.6) is running on a slightly different server setup, and you can safely assume anything is possible in the setup - modifications of core Mage code is possible, for example.

I'm looking for any hints on where to look - Magento configurations via the admin panel, local.xml changes, Apache rewrite rules...any tips on how to find out WHY this new cart isn't redirecting to /store/checkout/cart/ when I delete a product from my cart.

If you need more details, I'd be happy to provide them. We have a kinda funky setup that has been truly hacked together, and I'm also open to suggestions on how to set things up if it sounds like we're doing something wrong. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风尘浪孓 2024-10-27 11:52:16

这可能是旧消息,但我在 2011 年 12 月的 magento 1.5.10 中也遇到了同样的问题。
我通过编辑 CartController.php 成功解决了这个

问题

删除操作函数

替换

$this->_redirectReferer(Mage::getUrl('*/*'));

$this->_redirect('结帐/购物车');

不要复制和粘贴此内容,请确保输入它,并在结帐/购物车周围使用单引号

This may be old news, but I had the same issue in magento 1.5.10 in December 2011.
and I successfully addressed it by editing

CartController.php:

in

function deleteAction

replace

$this->_redirectReferer(Mage::getUrl('*/*'));

with

$this->_redirect('checkout/cart');

Don't copy and paste this, make sure you type it, and use single quotes around checkout/cart

心欲静而疯不止 2024-10-27 11:52:16

如果您已经检查了 B00MER 建议的设置,那么我认为您的下一步需要是通过请求处理流程进行实时调试。阅读我的 之前的回答,了解有关设置 Magento 调试环境的一些指导。

该答案也相关,因为它涉及 CartController 中的 updatePostAction,在这种情况下负责的方法相同。

if you've checked the setting that B00MER suggested, then I think that your next step needs to be to live debug your way through the request handling flow. Have a read of my previous answer for some pointers on getting your Magento debug environment setup.

That answer is also relevant because it involves the updatePostAction in the CartController, the same method that is responsible in this situation.

半暖夏伤 2024-10-27 11:52:16

为了重写核心文件,我们需要创建一个模块并进行以下更改。

public function deleteAction()
{
    if ($this->_validateFormKey()) {
        $id = (int)$this->getRequest()->getParam('id');
        if ($id) {
            try {
                $this->_getCart()->removeItem($id)
                    ->save();
            } catch (Exception $e) {
                $this->_getSession()->addError($this->__('Cannot remove the item.'));
                Mage::logException($e);
            }
        }
    } else {
        $this->_getSession()->addError($this->__('Cannot remove the item.'));
    }

    $this->_redirect('checkout/cart');
}

For rewriting the core file we need to create a module and make the following change.

public function deleteAction()
{
    if ($this->_validateFormKey()) {
        $id = (int)$this->getRequest()->getParam('id');
        if ($id) {
            try {
                $this->_getCart()->removeItem($id)
                    ->save();
            } catch (Exception $e) {
                $this->_getSession()->addError($this->__('Cannot remove the item.'));
                Mage::logException($e);
            }
        }
    } else {
        $this->_getSession()->addError($this->__('Cannot remove the item.'));
    }

    $this->_redirect('checkout/cart');
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文