小编fxx*_*fxx的帖子

在Magento中将产品添加到购物车时,如何设置"文件"类型的自定义选项?

使用我自己的控制器,我将产品添加到Magento购物车.它有3个自定义选项:2个下拉选项(颜色和大小)和文件选项(设计).将产品添加到购物车的代码是

// 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 …
Run Code Online (Sandbox Code Playgroud)

file magento cart option

5
推荐指数
1
解决办法
2366
查看次数

标签 统计

cart ×1

file ×1

magento ×1

option ×1