Magento – How to get required options in magento to add a product in cart

addtocartconfigurable-productcustom-optionssoap

I am trying to add a product to cart in Magento using Magento SOAP v1 API ,but am getting Please specify the product required option(s). error message.

The call happens like:

        $productArray[] = array(
            "product_id"=>"24",
            "qty"=>1
);
    $resultCartProductAdd = $client->call($session, "cart_product.add", array($shoppingCartId, $productArray));

I am unable to figure out how to find out what all options are needed to add a product to the cart using SOAP v1 . Any help will be greatly appreciated.

Best Answer

This options are called Custom Options in the admin section. They can be retrieved via the soap api if you have the product id.

//SOAP V1
$optionResult = $client->call($session, 'product_custom_option.list', 'product_id');
var_dump($optionResult);

//SOAP V2
$result = $proxy->catalogProductCustomOptionList($sessionId, 'product_id');
var_dump($result);

http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.list.html

Related Topic