magento 1.9 soap api xml call to update product custom attribute
-
14-04-2021 - |
Question
I am working on to update product msrp. Below code working for me:
$sku = 'AMC-2.0-10';
$update_data = array (
'additional_attributes' => array (
'single_data' => array (
array ('key' => 'msrp', 'value' => 88)
)
)
);
$mage_url = 'http://mystore.com/api/v2_soap?wsdl';
$mage_user = 'user';
$mage_api_key = 'pass';
$soap = new SoapClient( $mage_url );
$session_id = $soap->login( $mage_user, $mage_api_key );
$update = $soap->catalogProductUpdate($session_id, $sku, $update_data);
but when i try it with postman i get the error that 'Product not exists'
Please check and advise whats wrong in this xml call.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">r
<soapenv:Header/>r
<soapenv:Body>r
<urn:catalogProductUpdate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">r
<urn:sessionId xsi:type="xsd:string">48daca05f4e6432750199b6295509a24</urn:sessionId>
<urn:sku xsi:type="xsd:string">AMC-2.0-10</urn:sku>
<urn:productData>
<urn:additional_attributes>
<urn:single_data>
<item>
<key>msrp</key>
<value>77</value>
</item>
</urn:single_data>
</urn:additional_attributes>
</urn:productData>
</urn:catalogProductUpdate>
</soapenv:Body>r
</soapenv:Envelope>
Solution
Found the solution to above issue:
this code working fine:
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">r
<soapenv:Header/>
<soapenv:Body>
<urn:catalogProductUpdate>
<sessionId xsi:type="xsd:string">48daca05f4e6432750199b6295509a24</sessionId>
<product xsi:type="xsd:string">AMC-2.0-10</product>
<urn:productData>
<urn:additional_attributes>
<urn:single_data>
<item>
<key>msrp</key>
<value>67</value>
</item>
</urn:single_data>
</urn:additional_attributes>
</urn:productData>
</urn:catalogProductUpdate>
</soapenv:Body>
</soapenv:Envelope>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange