cancel
Showing results for 
Search instead for 
Did you mean: 

How to get option id's and values from configurable product?

How to get option id's and values from configurable product?

 

I am modifying phtml code were I have access to

$this which happens to be Mage_Checkout_Block_Cart_Item_Renderer_Configurable class

and

$_item = $this->getItem();
$_product = $_item->getProduct(); 

where product is a configurable product in a cart.

Based on this I need to get a list of option id (swatches) and their values.

1 REPLY 1

Re: How to get option id's and values from configurable product?

you can get the selected options and values via the following code : 

// get custom options value of cart items
    $options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
    $customOptions = $options['options'];
    if (!empty($customOptions)) {
        foreach ($customOptions as $option) {
            $optionTitle = $option['label'];
            $optionId = $option['option_id'];
            $optionType = $option['type'];
            $optionValue = $option['value'];
        }
    }

 

kindly Accept as a Solution if this works for you and give Kudos Smiley Happy