3

当我如下调用api函数时

<?php $result = $client->catalogProductInfo($session, $id, null, 'sku'); ?>

我收到以下错误。我很肯定所有传递的变量都设置正确,因为其他 magento api 函数工作得很好。

产品不存在错误:发生内部错误。

我假设这是调用语法的错误。我找不到使用 sku 而不是产品 ID调用catalogProductInfo的正确示例。文档http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html向我表明我的调用是正确的。

任何关于我做错了什么的想法都受到高度赞赏。

4

3 回答 3

5

尝试提交一个空格作为 SKU 的最后一个字符。例如,如果 SKU 是"1234"submit "1234 "

如果您提交的 sku 仅包含数字,则有时会出现此问题。

于 2013-08-16T15:05:43.580 回答
0

I think you hit on a problem with the optional arguments which your call can take. catalogProductInfo() can take five arguments, of which the first one is the sessionId; all the other arguments are passed to the method Mage_Catalog_Model_Product_Api_V2::info(), which takes them as follows:

public function info($productId, $store = null, $attributes = null, $identifierType = null)

As you can see, just the $productId is obligatory, the other arguments are optional. But, if you want to pass the $identifierType argument to the method, you have to pass as well all the other arguments. So, in your case, you omit one of the $store or $attributes arguments, and the method takes your sku as the $attributes argument. That produces your error.

So you either should pass the missing argument, or you can just omit the $identifierType argument. Magento can guess from the input at $productId which identifier type you pass (product ID or sku). The info() method calls the _getProduct() method, which in turn calls Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType). In this method Magento takes a guess about your $productId argument:

if ($identifierType === null) {
        if (is_string($productId) && !preg_match("/^[+-]?[1-9][0-9]*$|^0$/", $productId)) {
            $expectedIdType = 'sku';
        }
    }
于 2013-05-26T11:44:04.977 回答
0

您遗漏了 4. 参数。

功能是smth。像这样:

public catalogProductReturnEntity catalogProductInfo(
string sessionId,
string product,
string storeView,
**catalogProductRequestAttributes attributes,**
string productIdentifierType)

作为“属性”,您通过了“sku”。

于 2014-12-09T07:55:44.090 回答