开发者

Is it possible to set certain product attributes for a different store view using the Magento API?

We are currently using the Magento API for importing a b开发者_C百科unch of products into the store. But we now run into a problem where some product attributes should be translated into a different language.

And I was wondering if it is possible to do this using the Magento API, because I can't seem to find anything related to that problem.

We currently have 2 store views, 1 for the Dutch version of the site and one for the French version of the site.

Our current import code looks something like this:

$store_id = $soapClient->call($soapSession, 'catalog_product.currentStore', array('nl'));
echo("store_id: $store_id");
$new_product_data = array(
    'name' => 'NameInDutch',
    'short_description' => 'DescriptionInDutch',
    'price' => $price,
    'weight' => $weight,
    'websites' => array('base'),
    'status' => '1'
);
$new_product_id = $soapClient->call($soapSession, 'catalog_product.create', array('simple', 4, $sku, $new_product_data)); // 4 => 'Default' attribute set
$localized_product_data = array(
    'name' => 'NameInFrench',
    'short_description' => 'DescriptionInFrench'
);

$store_id = $soapClient->call($soapSession, 'catalog_product.currentStore', array('fr'));
echo("store_id: $store_id");
$soapClient->call($soapSession, 'catalog_product.update', array($sku, $localized_product_data ));

Now, the output of the echo statements differs, the first time it's 1 and the second time it's 2, so that doesn't seem to be problem. But apparently it doesn't matter for the API if we set that value.

The result is that on the 'catalog_product.update' call, the name 'NameInFrench' overwrites the default name 'NameInDutch'.

So my question is if something like this is possible using the Magento API, and how one would accomplish this?


Ok, I found the answer, apparently I overlooked a certain line in the Magento API docs, because the solution was right there.
So: you don't need to set the currentStore each time, you just need to append the store id or code to the update array:

$soapClient->call(
    $soapSession,
    'catalog_product.update',
    array($sku, $localized_product_data, 'fr')
);

This works perfectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜