I am having problems with the custom date field to add a product to my controller function.
So, I have to break / blow the Magento path and put it in params in AddProduct() as shown below.
try { $cart = Mage::getModel('checkout/cart'); $previousItemCount = $cart->getQuote()->getItemsCount(); if ($previousItemCount <= 0) { $cart->init(); } $params = $this->getRequest()->getParams(); $product = Mage::getModel('catalog/product')->load($params['product_id']); $date = explode('/', $params['product_dtinvoice']); $date = array( 'month' => $date[0], 'day' => $date[1], 'year' => $date[2], ); $cart->addProduct( $product, new Varien_Object(array( 'product' => $product->getId(), 'qty' => 1, 'options' => array( '4' => array( 'month' => $date['month'], 'day' => $date['day'], 'year' => $date['year'] ), '2' => $params['product_ean'], '3' => $params['product_serialnumber'], '1' => $params['product_seller'], ), )) ); $cart->save(); if ($previousItemCount < $cart->getQuote()->getItemsCount()) { $return = array('result' => true, 'msg' => ''); } else { $return = array('result' => false, 'msg' => 'Did not possible to add this product to cart. Please contact the administrator'); } $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($return)); } catch(Exception $e) { Mage::throwException($e->getMessage()); }
source share