How to get Custom Options Programmatically in Magento

前端 未结 7 2205
天涯浪人
天涯浪人 2020-12-09 05:20

I have a couple products at checkout that I need to be able to get all of the custom options that are selected for them through code.

Any help is much appreciated! <

7条回答
  •  清歌不尽
    2020-12-09 05:41

    We can also solve like that, that can display on checkout page.

     $items = Mage::getModel('checkout/cart')->getQuote()->getAllVisibleItems();
     foreach($items as $product) {
         $options = $product->getProduct()->getTypeInstance(true)->getOrderOptions($product->getProduct());
         if ($options)
         {
            if (isset($options['options']))
            {
               $result = $options['options'];
            }
            if(count($result)>0){
               foreach($result as $key =>$value){
                    $resultoption =  $value['value'];
               }
            }
        }
    

提交回复
热议问题