使用数字SKU时Magento 1.6.0 API产品更新不起作用 [英] Magento 1.6.0 API product update not working when using numerical SKU
问题描述
我的产品都使用数字SKU,但是使用API进行产品更新时似乎会引起问题.
My products all use numerical SKUs, but it seems to cause a problem when using the API to do product update.
根据 API文档,您可以使用产品ID或SKU.
According to the API doc, you can use either product ID or SKU.
参数:
- 混合产品-产品ID或Sku
- array productData-属性值数组
- 混合storeView-商店视图ID或代码(可选)
但是,完全数值的SKU似乎无效. 我确信在某处有一些代码可以检查该值是否为数字,并假定我必须提供产品ID.
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.
我还在某个地方读到了您可以传递第4个参数以指定您正在使用sku的地方,但这还是行不通的.
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?
推荐答案
简短的回答是,某处存在一个错误,导致无法正确设置product.update
的最后一个参数(或者Varien尚未实现它).也给方法product.info
带来了问题.
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
.
一种快速的解决方法(如果您不介意丢失通过ID更新的选项),只需在Product API update()
方法中设置$identifierType
):
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 ):
在app/code/core/Mage/Catalog/Model/Product/Api.php
l.198
public function update($productId, $productData, $store = null, $identifierType = 'sku')
最后在app/code/core/Mage/Catalog/Helper/Product.php的l.427左右的方法getProduct()的if($ idBySku)条件下加载产品
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.
这篇关于使用数字SKU时Magento 1.6.0 API产品更新不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!