Magento 和 Wordpress 不共享会话数据(例如购物车中的商品数量)
在 WP 模板的 index.php 文件中使用下面的代码:
require_once '/Users/xxx/Documents/Projects/honora/trunk/app/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
Mage::log(Mage::helper('checkout/cart')->getCart()->getItemsCount());
理论上应该可以在 Mage 日志的 Wordpress 博客中给出我的购物车中的商品数量。在我拥有的一个版本的 Magento 中将商品添加到购物车后,我到达博客时的日志显示我正确地拥有 1 件商品。然而,在完全不同的 Magento 版本中,情况并非如此,而是记录 0。
现在我知道这是一个相当模糊的问题,但任何人都可以提出一些可能的解决方案或方法来检查正在发生的情况吗?我不认为这一定是 WP 的问题,而是认为这是 Mage::app() 和会话模型调用之间发生的事情。
任何帮助将不胜感激。
Using the code below in the index.php file of a WP template:
require_once '/Users/xxx/Documents/Projects/honora/trunk/app/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
Mage::log(Mage::helper('checkout/cart')->getCart()->getItemsCount());
should in theory give me the number of items in my cart in a Wordpress blog in the Mage log. After adding an item to my cart in one version of Magento I have, the log of when I arrive at my blog shows that I correctly have 1 item. However, in a completely different version of Magento, this isn't the case, and instead logs 0.
Now I know that this is a pretty vague question, but can anyone throw out some possible solutions or ways to check into what's going on? I don't believe it's necessarily an issue with WP, instead believing it's something that's happening between Mage::app() and the call to the session model.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能想在您的 WordPress 中尝试这个,而不是您发布的代码。在 1.4.x 中工作正常
http://wordpress.org/extend/plugins/mage-启动器/
May want to try this in your Wordpress, instead of the code you posted. Working fine for me in 1.4.x
http://wordpress.org/extend/plugins/mage-enabler/
我意识到这是一个老问题,但我们新的 Wordgento 插件 应该可以帮助人们将来解决这个问题。
I realise this is an old question, but our new Wordgento plugin should help people solve this issue in future.