Magento 使用自定义选项文件或图像将产品添加到购物车
已尝试使用以下代码,但在尝试添加文件类型选项时卡住Magento 使用自定义选项文件或图像将产品添加到购物车,magento,magento-1.7,Magento,Magento 1.7,已尝试使用以下代码,但在尝试添加文件类型选项时卡住 $product = Mage::getModel('catalog/product')->load(611); $cart = Mage::getModel('checkout/cart'); $cart->init(); //the file stored in http://domain/img1.png $image= 'img1.png'; $params = array( 'product' => $p
$product = Mage::getModel('catalog/product')->load(611);
$cart = Mage::getModel('checkout/cart');
$cart->init();
//the file stored in http://domain/img1.png
$image= 'img1.png';
$params = array(
'product' => $product->getId(), // This would be $product->getId()
'qty' => 1,
'options' => array(
2 => "text field here",
1 => array(
'quote_path' => Mage::getBaseDir() . $image,
'secret_key' => substr(md5(file_get_contents(Mage::getBaseDir() . $image)), 0, 20)
),
),
'options_1_file_action'=>'save_new',
);
try {
$cart->addProduct($product, new Varien_Object($params));
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
$cart->save();
echo 'success';
}
catch (Exception $ex) {
echo $ex->getMessage();
}
找到了这个,但答案不清楚
提前感谢:)