首页 文章

在magento中获取自定义属性值

提问于
浏览
0

我已在报价会话中保存自定义属性,但无法在购物车页面中接收其值 . 我想在产品会话中保存自定义属性并在购物车中获取 Value . 我用代码

$quoteItem = $cart->getQuote()->getItemById($productId);
$quoteItem->addOption(array('label' => 'buymode', 'code' => 'buymode', 'value' => '2222'));
$quoteItem->save();

1 回答

  • 0

    试试这个:

    $quoteItems = $quote->getAllItems();
    $itemId = null;
    foreach($quoteItems as $item){
     if($item->getProductId() == $productId){
       $itemId = $item->getId();
     }
    }
    if($itemId){
    $quoteItem = $cart->getQuote()->getItemById($itemId);
     $quoteItem->addOption(array('label' => 'buymode', 'code' => 'buymode', 'value' => '2222'));
    $quoteItem->save();
    }
    

相关问题