已尝试使用以下代码,但在尝试添加文件的选项类型
时卡住了$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();
}
发现了这个,但答案并不清楚
How to set a custom option of type "file" when adding a product to the cart in Magento?
提前致谢:)