1

i try to add product to cart wih this code :

    $proxy = new SoapClient('http://example.com/index.php/api/v2_soap/?wsdl'); 
    try{
    $result = $proxy->shoppingCartProductAdd($sessionID, $cartID, array(array(
    'product_id' => $productID,
    'sku' => $sku,
    'qty' => $qty,
    'options' => null,
    'bundle_option' => null,
    'bundle_option_qty' => null,
    'links' => null
    )));  

    } catch(SoapFault $e){

       $result = $e->getMessage();
       }

i found it from this link : Magento API

on link example it`s pass null for options if i want to add options like color or size or ... to product and then add the prodoct to cart what should i do ?

4

As you can see in the documentation from your link above, the shoppingCartProductEntity array attribute "options" is an associativeArray in the form of option_id => content.

I found a nice answer on stackoverflow "Setting Custom Options while adding a product to cart via SOAP in Magento" regarding this problem and the declaration as provided in the documentation does not seem correct.

The right way seems to be:

'options' => 
        array(
          0 => 
            array(
              'key' => 1
              'value' => 2),
          1 => 
            array(
              'key' => 3
              'value' => 4),              
        )
  • is 'key' title of option ? and 'value' value of option ? like Color , Red ? – mahdi Aug 14 '14 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.