Magento的:增加产品两次车,具有不同的属性! [英] Magento: add product twice to cart, with different attributes!

查看:170
本文介绍了Magento的:增加产品两次车,具有不同的属性!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在这工作了一整天,但我无法找到任何解决方法:

I have been working with this for a whole day but i cannot find any solution:

我有一个产品(镜片),它具有相同的属性,但用户可以选择一个属性为一只眼睛,另一组另一个属性设置。

I have a product (lenses), which has identical attributes, but user can choose one attribute set for one eye and another attribute set for another.

在前端我就OK了,看它这里

On the frontend I got it ok, see it here.

因此​​,用户可以选择用于左眼或右眼的属性,但它是相同的产品

So the user can select attributes for left or right eye, but it is the same product.

我建立一个功能,它应该采取一个产品在购物车(之前保存),添加其他属性集,所以应该有两款产品在购物车中。什么情况是有两个产品,但与同组的属性???

I build a function, which should take a product in a cart (before save), add other set of attributes, so there should be two products in the cart. What happens is there are two products, but with the same set of attributes???

下面是函数的代码片段:

$req = Mage::app()->getRequest(); 
$request[’qty’] = 1; 
$request[’product’] = 15; 
$request[’uenc’] = $req->get(’uenc’); 
$request[’options’][1] = 1; 
$request[’options’][3] = 5; 
$request[’options’][2] = 3; 
$reqo = new Varien_Object($request); 
$newitem = $quote->addProduct($founditem->getProduct(), $reqo); 

//add another one ------------------------------------------ 

$request[’qty’] = 1; 
$request[’product’] = 15; 
$request[’uenc’] = $req->get(’uenc’); 
$request[’options’][1] = 2; 
$request[’options’][3] = 6; 
$request[’options’][2] = 4; 
$reqo = new Varien_Object($request); 
$newitem = $quote->addProduct($founditem->getProduct(), $reqo);

或者另一个测试,与其他一些功能(再次,产品附加值,用2量,但相同的属性...):

Or another test, with some other functions (again, product added, with 2 quantity , but same attributes...):

$req = Mage::app()->getRequest(); 
$request[’qty’] = 1; 
$request[’product’] = 15; 
$request[’uenc’] = $req->get(’uenc’); 
$request[’options’][1] = 2; 
$request[’options’][3] = 6; 
$request[’options’][2] = 4;

$product = $founditem->getProduct();

$cart = Mage::getSingleton(’checkout/cart’); 
//delete all first… 
$cart->getItems()->clear()->save(); 
$reqo = new Varien_Object($request);

$cart->addProduct($founditem->getProduct(), $reqo); 
$cart->getItems()->save();

$request[’options’][1] = 1; 
$request[’options’][3] = 5; 
$request[’options’][2] = 3;

$reqo = new Varien_Object($request);

$cart->addProduct($founditem->getProduct(), $reqo); 
$cart->getItems()->save();

我真的不知道有什么更多的事情要做,请任何建议,这是在Magento我的第一个模块...

I really don't know what more to do, please any advice, this is my first module in Magento…

感谢你,彼得

推荐答案

进入课堂 Mage_Sales_Model_Quote
并搜索方法 getItemByProduct($产品)并使其返回false; 所有的时间。
请注意,这可能与最小&放大器干扰; 最高获准在车产品。

Go to class Mage_Sales_Model_Quote and search for the method getItemByProduct($product) and make it return false; all the time. Be careful, this might interfere with the minimum & maximum allowed in cart for products.

这篇关于Magento的:增加产品两次车,具有不同的属性!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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