Sachin Vairagi
Sachin Vairagi

Reputation: 5334

Magento 1.9 - SOAP V1 - One item of products do not have identifier or sku

can anyone please help me to get rid out of this message - One item of products do not have identifier or sku here is my codes -

$proxy = new SoapClient('http://www.testdomain.com/api/soap/?wsdl');
$sessionId = $proxy->login('myapi', 'test@123');

//$quoteId = $proxy->call( $sessionId, 'cart.create', array( 'default' ) );


$arrProducts = array(
    array(
        "product_id" => 12,
        "qty" => 1,
        "options" => array(         
            "267" => 653,
            "268" => array('date' => '12/8/2016'),
         )
    ),
    array(
        "sku" => 20707,
        "quantity" => 4,
        "store_id" => 1
    )
);
try {
        $resultCartProductAdd = $proxy->call(
            $sessionId,
            "cart_product.add",
            array(
                991,
                array($arrProducts)
            )
        );
} catch (SoapFault $e) {
    $message = $e->getMessage();
    print_r($message);
}

I have tried all examples found here - http://devdocs.magento.com/guides/m1x/api/soap/checkout/cartProduct/cart_product.add.html but could not success , any help would be really appreciated, thanks.

Upvotes: 2

Views: 398

Answers (1)

Sachin Vairagi
Sachin Vairagi

Reputation: 5334

Finally I resolved it as -

$proxy = new SoapClient('http://www.testdomain.com/api/soap/?wsdl');
$sessionId = $proxy->login('apitest', 'test@123');

//$quoteId = $proxy->call( $sessionId, 'cart.create', array( 'default' ) );


$arrProducts = array(
    array(
        "product_id" => 12,
        "quantity" => 1,
        "options" => array(         
            "267" => 653,
            "268" => array('date' => '12/8/2016'),
         ),
    "sku" => 20707,
        "quantity" => 4,
        "store_id" => 1
    )
);
try {
        $resultCartProductAdd = $proxy->call(
            $sessionId,
            "cart_product.add",
            array(
                985,
                $arrProducts
            )
        );
    print_r($resultCartProductAdd);
} catch (SoapFault $e) {
    $message = $e->getMessage();
    print_r($message);
}

I have updated $arrProducts array and it resolved my issue. Hope this will help others , thank you.

Upvotes: 4

Related Questions