Using my own controller, I add the product to the Magento basket. It has 3 configurable options: 2 drop-down lists (color and size) and a file option (design). The code that adds the product to the cart,
// obtain the shopping cart $cart = Mage::getSingleton('checkout/cart'); // load the product $product = Mage::getModel('catalog/product') ->load($productId); // do some magic to obtain the select ids for color and size ($selectedSize and $selectedColor) // ... // define the buy request params $params = array( 'product' => $productId, 'qty' => $quantity, 'options' => array( $customOptionSize->getId() => $selectedSize, $customOptionColor->getId() => $selectedColor, // set the file option, but how? ), ); // add this configuration to cart $cart->addProduct($product, $paramObject); $cart->save(); // set the cart as updated Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
My question is: How can I attach a specific file to a design option?
The file has already been transferred to the server (actually through the request). I could, however, fake the download if necessary. But so far I have not found a single source of information about setting up custom file parameters ...
My best guess from the tour through Magento sources is that additional data is required for the purchase request (not in the parameters, but in the params object), for example: option_123_file => something, but I didn’t understand what exactly was needed . This part of Magento's sources is most likely not so straightforward. Thanks for any help.
source share