3
votes

When i call the api function as follows

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

I get the following error. I'm positive that all the passed variables are set correctly, as other magento api functions work just fine.

Product not exists Error: An Internal Error Has Occurred.

I'm assuming that it's a fault with the call syntax. I couldn't find a proper example of calling catalogProductInfo with sku instead of product id. The documentation http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html suggests to me that my call is correct.

Any ideas as to what I'm doing wrong are highly appreciated.

3

3 Answers

5
votes

Try to submit a space as last character of your SKU. e.g. if SKU is "1234" submit "1234 ".

This issue sometimes occurs, if your submitted sku only contains numbers.

0
votes

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';
        }
    }
0
votes

You left out the 4. param.

Function is smth. like this:

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

As "attributes" you passed "sku".