In Magento 1.5, accessing the catalogProductInfo API call from C# like this works with non-numeric SKUs:
catalogProductRequestAttributes fetchattrib = new catalogProductRequestAttributes();
fetchattrib.attributes = new string[] { "name", "description", "and_so_on"};
fetchattrib.additional_attributes = new string[] { "custom_attribs_go_here"};
string storeView = null;
string productIdentifierType = null;
catalogProductReturnEntity ret = m_magentoClient.catalogProductInfo(
sessionId, sku, storeView, fetchattrib, productIdentifierType);
But with numeric SKUs I get 'Product not exists' errors.
Presumably this is because Magento cannot tell whether you are passing it a product_id or an SKU. Setting the productIdentifierType to 'sku' should fix that, in theory, according to all the documentation I can find:
...
string productIdentifierType = "sku";
...
But it doesn't fix it.
In fact it seems to make it worse, Magento then stops finding non-numeric SKUS.
So presumably "sku"
is not the right value to pass.
Anyone got any ideas?
Short answer is that there's a bug somewhere preventing the last param of product.update
from being set properly (or maybe Varien haven't yet implemented it), which also presents a problem for the method product.info
.
A quick workaround (if you don't mind losing the option to update by ID) is just to set the $identifierType
in the Product API update()
method ):
In app/code/core/Mage/Catalog/Model/Product/Api.php
l.198
public function update($productId, $productData, $store = null, $identifierType = 'sku')
And finally load the product within the if ($idBySku) condition of the method getProduct() around l.427 of app/code/core/Mage/Catalog/Helper/Product.php
$productId = $idBySku;
$product->load($productId);
It's a bit of a fudge. I'll have a look for a better workaround as an override; otherwise, maybe someone else can post a better solution.
There is a workaround for pure numeric or mixed SKU, that works quiet well for me.
Just add a whitespace at the end of your SKU. Magento will interpret the value as a SKU, because whitespace is non numeric. Internaly Magento trims the whitespace later
This works perfectly from Magento 1.4.x - 1.9. (Edit: Thanks at Brett for testing with 1.9)
Example:
catalogProductReturnEntity ret = m_magentoClient.catalogProductInfo(sessionId, sku+" ", storeView, fetchattrib, productIdentifierType);