Magento 1.9-未向注销用户添加产品到购物篮 [英] Magento 1.9 - Product not being added to basket for logged out users

查看:62
本文介绍了Magento 1.9-未向注销用户添加产品到购物篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像大多数与Magento相关的问题一样,经常需要将头撞在墙上才能找到解决方案.但是这次,什么都没有.

Like most Magento related issues, banging your head against the wall is often necessary to find a solution. This time however, nothing.

对于退出并试图将商品添加到空购物车的客户来说,我遇到了一个奇怪的问题.不适用于某些特定的产品类型.

I am having a strange issue for customers who are logged out and trying to add items to an empty cart. It won't work for some specific product types.

我扩展了购物车控制器,以增加对用户输入值的支持,而不是标准的Magento下拉方法.这意味着用户可能会输入一个尚不存在的数字作为我的可配置产品的关联产品(请参见下图).

I have extended the Cart Controller to add support for user inputted values instead of the standard Magento dropdown approach. This means that users could potentially input a number that doesn't yet exist yet as an associated product to my configurable (see image below).

因此,我已经实现了一个系统,如果该产品不存在,它将创建该产品,然后将其添加到购物篮中.这对于登录用户(甚至是在购物篮中具有现有项目的注销用户)非常有效.但是,即使注销的用户添加了成功消息,也无法使用购物车.

Therefore I have implemented a system that will create the product should it not exist, then add it to the basket. This works beautifully for logged in users (and even logged out users with existing items in the basket). But it doesn't work when a logged out user has an empty cart despite it adding the success message.

我最初的想法是这是与会话相关的问题,因为没有帐户的用户无法访问数据库,并且还因为一旦注销的用户在购物篮中已有项目,它就会随机开始工作.

My initial thought was that it was a Session related issue because users without accounts don't access the database, and also because it randomly starts working once a logged out user has items existing in the basket.

我尝试刷新会话,初始化购物车,添加两次以取得良好效果,但仍然没有执行任何操作.任何帮助,将不胜感激.

I have attempted refreshing sessions, initialising the cart, adding it twice for good measure but still nothing. Any help on this would be greatly appreciated.

非常感谢.

推荐答案

感谢 Bezzie 它原来是一个仿真问题.我从来不知道这样的事情存在.每当您需要在管理员之外执行管理员功能时,都必须将当前商店设置为"admin".因此,在Magneto 1.5中引入了仿真. 此处来源.

Thanks to Bezzie It turned out to be an emulation problem. I never knew such a thing existed. Whenever you need to do admin functionality outside the admin you must set the current store as "admin". Emulation was introduced in Magneto 1.5 for this reason. Source here.

$appEmulation = Mage::getSingleton('core/app_emulation');

//Start environment emulation of the specified store
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation(Mage_Core_Model_App::ADMIN_STORE_ID);

/*
 * Any code thrown here will be executed as we are currently running that store
 * with applied locale, design and similar
 */

//Stop environment emulation and restore original store
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);

当您看到它时,这似乎很明显,但是弄清楚这一点真是太疯狂了!谢谢Bezzie

It seems obvious when you look at it, but figuring this one out was mad! Thanks Bezzie

这篇关于Magento 1.9-未向注销用户添加产品到购物篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆