I'm working in a module that will add products to cart via chatbot, and I'm having some issues when the product has custom options. Since do not know the possible options required to the product, I'm trying to "force" add a product with custom option (or not) to the cart, but everytime I'm getting a message asking to specify some product custom option:
2017-02-26T17:24:28+00:00 ERR (3):
exception 'Mage_Core_Exception' with message 'Please specify product link(s).' in /home/werules/testbots.tk/store/app/Mage.php:595
Stack trace:
#0 /home/werules/store/app/code/core/Mage/Checkout/Model/Cart.php(287): Mage::throwException('Please specify ...')
#1 /home/werules/store/app/code/community/Werules/Chatbot/Model/Chatdata.php(243): Mage_Checkout_Model_Cart->addProduct(Object(Mage_Catalog_Model_Product), Array)
Here is my code so far:
$product = Mage::getModel('catalog/product')->load($prodId);
$product->setSkipCheckRequiredOption(true);
$cart->addProduct($product, array());
$cart->save();
$checkout->setCartWasUpdated(true);
I'm using setSkipCheckRequiredOption
but it dosen't seems to be working.
How can I accomplish that? Either ignoring any requirements or setting them to any default value would work for me.
Best