Skip to main content

SOLVED - Magento 2 Get product_options value from sales_order_item

added 1 character in body
Source Link
Magento Learner
  • 2.1k
  • 3
  • 41
  • 90

In sales_order_item table, there's a column product_options to store some custom values.

I need to get the deliverydates from the following value (value from a order objectthe db column product_options)

{"info_buyRequest":{"qty":"1","super_attribute":{"137":"2803","93":"17717"},"product":"37702","deliverydates":"2018-04-07"}}

I have tried the following code, but is not working.

    foreach ($this->order->getAllVisibleItems() as $orderItem) {
        $options = $orderItem->getProductOptions(); 
        #$options = $orderItem->getProduct()->getTypeInstance(true)->getOrderOptions($orderItem->getProduct());
        if(!empty($options['options'])) {        
            foreach ($options['options'] as $option) {
                if ($option['label'] == 'deliverydates'){
                    $deliverydate = $option['value'];
                }
            }
        }

In sales_order_item table, there's a column product_options to store some custom values.

I need to get the deliverydates from the following value from a order object

{"info_buyRequest":{"qty":"1","super_attribute":{"137":"2803","93":"17717"},"product":"37702","deliverydates":"2018-04-07"}}

I have tried the following code, but is not working.

    foreach ($this->order->getAllVisibleItems() as $orderItem) {
        $options = $orderItem->getProductOptions(); 
        #$options = $orderItem->getProduct()->getTypeInstance(true)->getOrderOptions($orderItem->getProduct());
        if(!empty($options['options'])) {        
            foreach ($options['options'] as $option) {
                if ($option['label'] == 'deliverydates'){
                    $deliverydate = $option['value'];
                }
            }
        }

In sales_order_item table, there's a column product_options to store some custom values.

I need to get the deliverydates from the following value (value from the db column product_options)

{"info_buyRequest":{"qty":"1","super_attribute":{"137":"2803","93":"17717"},"product":"37702","deliverydates":"2018-04-07"}}

I have tried the following code, but is not working.

    foreach ($this->order->getAllVisibleItems() as $orderItem) {
        $options = $orderItem->getProductOptions(); 
        #$options = $orderItem->getProduct()->getTypeInstance(true)->getOrderOptions($orderItem->getProduct());
        if(!empty($options['options'])) {        
            foreach ($options['options'] as $option) {
                if ($option['label'] == 'deliverydates'){
                    $deliverydate = $option['value'];
                }
            }
        }
added 1 character in body
Source Link
Magento Learner
  • 2.1k
  • 3
  • 41
  • 90

In sales_order_item table, there's a column product_options to store some custom values.

I need to get the deliverydates from the following value from a order object

{"info_buyRequest":{"qty":"1","super_attribute":{"137":"2803","93":"17717"},"product":"37702","deliverydates":"2018-04-07"}}

I have tried the following code, but is not working.

    foreach ($this->order->getAllVisibleItems() as $orderItem) {
        $options = $orderItem->getProductOptions(); 
        #$options = $orderItem->getProduct()->getTypeInstance(true)->getOrderOptions($orderItem->getProduct());
        if(!empty($options['options'])) {        
            foreach ($options['options'] as $option) {
                if ($option['label'] === 'deliverydates'){
                    $deliverydate = $option['value'];
                }
            }
        }

In sales_order_item table, there's a column product_options to store some custom values.

I need to get the deliverydates from the following value from a order object

{"info_buyRequest":{"qty":"1","super_attribute":{"137":"2803","93":"17717"},"product":"37702","deliverydates":"2018-04-07"}}

I have tried the following code, but is not working.

    foreach ($this->order->getAllVisibleItems() as $orderItem) {
        $options = $orderItem->getProductOptions(); 
        #$options = $orderItem->getProduct()->getTypeInstance(true)->getOrderOptions($orderItem->getProduct());
        if(!empty($options['options'])) {        
            foreach ($options['options'] as $option) {
                if ($option['label'] = 'deliverydates'){
                    $deliverydate = $option['value'];
                }
            }
        }

In sales_order_item table, there's a column product_options to store some custom values.

I need to get the deliverydates from the following value from a order object

{"info_buyRequest":{"qty":"1","super_attribute":{"137":"2803","93":"17717"},"product":"37702","deliverydates":"2018-04-07"}}

I have tried the following code, but is not working.

    foreach ($this->order->getAllVisibleItems() as $orderItem) {
        $options = $orderItem->getProductOptions(); 
        #$options = $orderItem->getProduct()->getTypeInstance(true)->getOrderOptions($orderItem->getProduct());
        if(!empty($options['options'])) {        
            foreach ($options['options'] as $option) {
                if ($option['label'] == 'deliverydates'){
                    $deliverydate = $option['value'];
                }
            }
        }
Source Link
Magento Learner
  • 2.1k
  • 3
  • 41
  • 90
Loading