【问题标题】:magento add to wishlist message in product details pagemagento 添加到产品详细信息页面中的愿望清单消息
【发布时间】:2016-03-25 19:15:02
【问题描述】:

我想在产品详细信息页面中显示愿望清单成功消息。我已经更改了重定向部分。现在我的页面在将产品添加到愿望清单后重定向到同一页面。但我需要在同一页面中显示消息。请帮助..提前谢谢。 P.S.- 我不想使用 ajax 添加到愿望清单功能。

【问题讨论】:

  • 如果您知道通过 ajax 功能可以实现,那么您为什么在这里发布这样的问题。
  • 我投票结束这个问题,因为 Stack Overflow 是一个programming-related 问答网站。您的问题与编程无关。也许你应该把它发到magento.stackexchange.com 上?
  • @sagar:因为我需要在页面加载中更新此功能。消息现在将出现在主页上。但是我需要在这部分删除该消息。我可以使用模块但那里是你发现的某些东西来收集你的知识..我认为这还不错..
  • @Enigmativity:请让我知道您如何相信这个问题与编程无关。我需要适当的编码解决方案。
  • 请注意您的magento版本。

标签: magento magento-1.9


【解决方案1】:

Magento 会话模型,即核心/会话、客户/会话和目录/会话等。

要添加消息,您可以使用“app\code\core\Mage\Wishlist\controllers\IndexController.php”:

动作:addAction()

查找:

$session->addSuccess($message);

下面写下这段代码:

Mage::getSingleton('catalog/session')->addSuccess($message);

然后添加错误信息:

查找:

catch (Mage_Core_Exception $e) {
            $session->addError($this->__('An error occurred while adding item to wishlist: %s', $e->getMessage()));
        }
        catch (Exception $e) {
            $session->addError($this->__('An error occurred while adding item to wishlist.'));
        }

替换为以下代码:

catch (Mage_Core_Exception $e) {
            $session->addError($this->__('An error occurred while adding item to wishlist: %s', $e->getMessage()));
            $error_msg = $this->__('An error occurred while adding item to wishlist: %s', $e->getMessage());
            Mage::getSingleton('catalog/session')->addError($error_msg);
        } catch (Exception $e) {
            $session->addError($this->__('An error occurred while adding item to wishlist.'));
            Mage::getSingleton('catalog/session')->addError('An error occurred while adding item to wishlist.');
        }

如果“目录/会话”不起作用,请尝试“核心/会话”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    相关资源
    最近更新 更多