Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

SKU Should NOT BE NUMBER??  problem in Product_Media API Bug? , error code 101
 
wakamagento
Jr. Member
 
Total Posts:  2
Joined:  2013-01-26
 

I find there is a SKU problem with product_media API

If I want to creat a image to an item, I use this API. but it is failed. the REASON IS CAN NOT FIND PRODUCT.error code 101.
Here is the test .
H1, I had created an item with SKU 5000093
H2, I had used catalogInventoryStockItemUpdate API and it worked successfuly.

Now here is the code for Product_Media API
--------------------------------------------------------------
$proxy = new SoapClient(’http://mag2.xxxxx.com/api/soap/?wsdl’); // host
$sessionId = $proxy->login(’apiusexxxx’, ‘123xxxxxxxxx’);
$newImage = array(
‘file’ => array(
‘name’ => ‘5000093’,
‘content’ => base64_encode(file_get_contents(’http://www.xxxxxxxxxx.com/images/5000093.jpg’)),
‘mime’ => ‘image/jpeg’
),
‘label’ => ‘Cool Image Through Soap2’,
‘position’ => 1,
‘types’ => array(’image’, ‘small_image’, ‘thumbnail’),
‘exclude’ => 0
);

echo $imageFilename = $proxy->call($sessionId, ‘product_media.create’, array(’5000093’, $newImage));

It return error message 101

After many many times tests. I finaly find out that if I change the item SKU(5000093) to (S5000093) MANUALY.
and rewrite the code like this
$imageFilename = $proxy->call($sessionId, ‘product_media.create’, array(’S5000093’, $newImage));

and you guess what? It worked!!

Can anybody meet the same problem like me?
All my SKU is number, to resolve the problem. should I add a letter infront of my SKU?
like
S5990999
S2645968
T3453939
.....

It will be a real problem or disaster :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
nathus
Sr. Member
 
Total Posts:  93
Joined:  2008-12-13
Twin Cities, MN
 

One thing I have found in the past is that adding a space at the end of your SKU in the API call usually will do the trick.

echo $imageFilename $proxy->call($sessionId'product_media.create', array('5000093 '$newImage));

Though the better way would be to use the 4th parameter of the api method which allows you to specify wither it is a product id or sku.
http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.create.html

The below should work (haven’t tested)

echo $imageFilename $proxy->call($sessionId'product_media.create', array('5000093'$newImagenull'sku'));
 
Magento Community Magento Community
Magento Community
Magento Community
 
wakamagento
Jr. Member
 
Total Posts:  2
Joined:  2013-01-26
 

yes. right find the reason now.

$product = $this->_initProduct($productId, $store, $identifierType);

....
if ($identifierType == null) {

if (is_string($productId) && !preg_match("/^[+-]?[1-9][0-9]*$|^0$/", $productId)) {
$identifierType = ‘sku’;
$loadByIdOnFalse = true;

} else {

$identifierType = ‘id’;

}

smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top