David Rodrigues
David Rodrigues

Reputation: 162

"101: Product not exists." (Magento API) product.update

I saw the documentation but I still not finding the error on my code.

I am trying to add a product from excel file to Magento System, and then update it on each Store View (multi language shop).

For that, I've done the following PHP script. On this code, I'm reading only one Excel row (just to show you how it works) and then i am adding it to Magento (actually that's working) and then I am trying to Update stuff (gives the error). Be aware that $col[9] is the var that saves the SKU.

Note: I am using SOAP, but not V2.

$rowdata=$sheet->rangeToArray('A' . $row.':'.$maxcol . $row, NULL, TRUE, FALSE);
$col=$rowdata[0];
//$soap is the client. $session_id is the logged in SOAP session.
$attributeSets = $soap->call($session_id, 'product_attribute_set.list');
$attributeSet = current($attributeSets);
$result = $soap->call($session_id, 'catalog_product.create', array('simple',     $attributeSet['set_id'], $col[9], array(
    'categories' => array(2),
    'websites' => array(1),
    'name' => $col[1],
    'description' => $col[10],
    'short_description' => $col[13],
    'weight' => '10',
    'status' => '1',
    'url_key' => 'product-url-key',
    'url_path' => 'product-url-path',
    'visibility' => '4',
    'price' => $col[20],
    'tax_class_id' => 1,
    'meta_title' => 'Product meta title',
    'meta_keyword' => 'Product meta keyword',
    'meta_description' => 'Product meta description'
)));
var_dump ($result);
$updatearray=  array(
    'name' => $col[2],
    'description' => $col[11],
    'short_description' => $col[14]
);
$update = $soap->call($session_id, 'catalog_product.update',    array($col[9], $updatearray, 'fr'));
var_dump ($update);

I would appreciate any help you guys can give!

Upvotes: 0

Views: 754

Answers (1)

David Rodrigues
David Rodrigues

Reputation: 162

I just found the fix for this problem but it really makes no sense.

So, when we are sending the SKU by call, we need to send with an extra space. It means the $update needs to be like this:

 $soap->call($session_id, 'catalog_product.update',    array($col[9].' ', $updatearray, 'fr'));

Upvotes: 2

Related Questions