My products all use numerical SKUs, but it seems to cause a problem when using the API to do product update.
According to the API doc, you can use either product ID or SKU.
Arguments:
- mixed product - product ID or Sku
- array productData - array of attributes values
- mixed storeView - store view ID or code (optional)
But fully numerical SKUs don't seem to work. I'm convinced there is some code somewhere which checks if the value is numerical and assumes I must be supplying the product ID.
I also read somewhere you can pass in a 4th parameter to specify you are using sku, but that didn't work either.
$proxy->call($sessionId, 'product.update', array('123456', array('name'=>'Updated name1'), null, 'sku') );
Does anyone know how to get this working?
In a similar question TurmDrummer posted another workaround: https://stackoverflow.com/a/10915276/1598270
I liked this solution a bit better as a workaround because you aren't modifying any core code files, which I try to avoid.
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 methodproduct.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 APIupdate()
method ):In
app/code/core/Mage/Catalog/Model/Product/Api.php
l.198And 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
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.