Magento 1.6.0 API 产品更新在使用数字 SKU 时不起作用 [英] Magento 1.6.0 API product update not working when using numerical SKU

查看:20
本文介绍了Magento 1.6.0 API 产品更新在使用数字 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 没有)t 尚未实现它),这也为方法 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 更新的选项)只是在产品 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.

这篇关于Magento 1.6.0 API 产品更新在使用数字 SKU 时不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆