I'm using Magento CE 1.7.0.2 with SOAPv2 and WS-I.
I'm trying to update products with the catalogProductUpdate
-Method.
The description in the code example below gets updated, but the manufacturer-attribute (=select) doesn't.
The result of catalogProductUpdate
is bool(true)
.
I tried some (not too good, but I'm desperate 😉 ) variations such as:
- assign the integer value 777 to
$manufacturer->value
set the value - within/without the additional_attributes field set the product id (but I'm sure it need's to be set within additional_attributes)
- set the manufacturer-name as
$manufacturer->value
instead of the value 777
Code:
$newProductData = new stdClass();
$additionalAttrs = array();
$manufacturer = new stdClass();
$manufacturer->key = "manufacturer";
$manufacturer->value = "777";
$additionalAttrs['single_data'][] = $manufacturer;
$newProductData->description = "Description Test1";
$newProductData->additional_attributes = $additionalAttrs;
$result = $client->catalogProductUpdate((object)array('sessionId' => $sessionId,
'productId' => "2110000010058 ",
'productData' => (object)$newProductData,
NULL,
'sku'
));
Edit:
- I tested it with SOAPv2 without WS-I – works fine.
- I also created another attribute for testing with the same settings (Dropdown, Scope,…) which also doesn't get updated with SOAPv2 WS-I but does with SOAPv2. So these newly created attributes behave as the manufacturer-attribute.
- Trying to set the value of a text-field within the additional_attributes doesn't work either.
Any ideas, links, suggestions on this?
Link:
http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.update.html
Best Answer
I finally found the reason for the problem and the solution:
The problem: SOAPv2 with WS-I does not use the
single_data
andmulti_data
attributes. Therefore the check in/app/code/core/Mage/Catalog/Model/Product/Api/V2.php
in_prepareDataForSave
fails. The method_prepareDataForSave
checks forsingle_data
andmulti_data
which are both not part of the SOAP-Call, according to the WSDL for SOAPv2 with WS-I.SOAPv2 (WSDL) - catalogProductCreateEntity:
SOAPv2 with WS-I (WSDL) - catalogProductCreateEntity:
associativeArray is of type associativeEntity which includes key/value pairs. In SOAPv2 withous WS-I, the
catalogProductAdditionalAttributesEntity
is used (which consists of single_data and/or multi_data values which again include key/value pairs).This is the SOAPv2 WS-I part of the WSDL which describes the format of additional_attributes:
The check for additional_attributes
/app/code/core/Mage/Catalog/Model/Product/Api/V2.php
worded fine, but the check for single_data or multi_data always returned false.The solution:
I found another SOAP Problem here where the last answer was the solution to my problem: https://stackoverflow.com/a/9502311/865443). So I put this block in my code in
_prepareDataForSave
which solved the problem of setting the additional_attributes values:I hope this helps someone else encountering the same problem. I would also appreciate an explanation for this differencde between SOAPv2 and SOAPv2 WS-I and/or other ways which solved this problem.