I have been working with this all day, but I cannot find a solution:
I have a product (lenses) that has the same attributes, but the user can select one attribute set for one eye and another attribute set for the other.
In the interface, I got it ok, see here .
Thus, the user can select the attributes for the left or right eye, but this is the same product.
I create a function that should take the product to the basket (before saving), add another set of attributes, so there should be two products in the basket. What happens, there are two products, but with the same set of attributes ???
Here is a snippet of the function:
$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);
Or another test, with some other functions (again, with the addition of a product, with 2 quantities, but with the 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();
I really don't know what else needs to be done, please, any advice, this is my first module in Magento ...
Thanks Peter