从愿望清单中添加项目后,我需要更改默认操作。默认情况下,当您点击“添加到篮子”按钮时,您将被重定向到购物车。我希望用户被重定向回到愿望清单。

我也知道要去 管理员>系统>配置>默认配置>销售>结帐>购物车>“将产品重定向到购物车之后”:是或否 解决了我的问题,但我希望只能为愿望清单而不是全球,仅用于一家商店!

有帮助吗?

解决方案

您可以写一个观察者听post_dispatch事件

'controller_action_postdispatch_wishlist_index_cart'

并将对重定向的响应更改为愿望清单。

因此,创建一个新的模块/扩展名,并将以下内容添加到您的 config.xml:

<global>
    ...
    <events>
        ...
        <controller_action_postdispatch_wishlist_index_cart>
            <observers>
                <yourcompany_yourmodule>
                    <type>singleton</type>
                    <class>YourCompany_YourModule_Model_Observer</class>
                    <method>controllerActionPostdispatchWishlistIndexCart</method>
                </yourcompany_yourmodule>
            </observers>
        </controller_action_postdispatch_wishlist_index_cart>
    </events>
</global>

然后在你 Observer.php 添加以下方法:

public function controllerActionPostdispatchWishlistIndexCart()
{
    Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::app()->getRequest()->getServer('HTTP_REFERER'));
}

而已。每当您尝试将一些愿望清单中的东西添加到购物车中时,您都会将其重定向到愿望清单。

许可以下: CC-BY-SA归因
scroll top