Magento 1.5,数字SKU和productIdentifierType

在Magento 1.5中,从C#访问catalogProductInfo API调用,这适用于非数字SKU:

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); 

但是使用数字SKU,我得到“产品不存在”错误。
据推测,这是因为Magento无法判断您是将它传递给product_id还是SKU。 将productIdentifierType设置为’sku’应该在理论上根据我能找到的所有文档来解决这个问题:

 ... string productIdentifierType = "sku"; ... 

但它并没有解决它。
事实上,它似乎使情况变得更糟,Magento然后停止寻找非数字SKUS。
所以推测"sku"不是正确的价值。

有人有任何想法吗?

简短的回答是,有一个错误阻止了product.update的最后一个参数被正确设置(或者Varien还没有实现它),这也给方法product.info带来了问题。

快速解决方法(如果您不介意丢失按ID更新的选项)只是在Product API update()方法中设置$identifierType

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)条件下加载产品

 $productId = $idBySku; $product->load($productId); 

这有点像软糖。 我将寻找一个更好的解决方法作为覆盖; 否则,也许其他人可以发布更好的解决方案。

纯数字或混合SKU有一个解决方法,对我来说很安静。

只需在SKU末尾添加一个空格。 Magento会将该值解释为SKU,因为空格是非数字的。 Internaly Magento后来修剪了空白

这完全适用于Magento 1.4.x – 1.9。 (编辑:感谢Brett用1.9进行测试)

例:

  catalogProductReturnEntity ret = m_magentoClient.catalogProductInfo(sessionId, sku+" ", storeView, fetchattrib, productIdentifierType);