I'm trying to save product to magento from frontend programmatically. Here, I have two stores, one for german language and another one for english language. But I need to maintain the same product for both.

$product = Mage::getModel('catalog/product');
foreach($variables as $key => $value){ //where key contains attribute code and value as values
   $product->setData($key, $value);

With help of above code, the product which I tried to save gets saved perfectly for "all stores view". But some fields values are not updated for the english and german stores because of the use default value uncheck. Can anyone guide how to do?

Please note I'm using multiple stores only for language translation.


So, you have some attributes that have to be set specifically for the English and German stores? To set an attribute on a product scoped to one store you need to set it like this:

$product->setStoreId($store_id)->setData($key, $value);

After you set the global attributes you could probably do something like this

$stores = Mage::app()->getStores();
foreach ($stores as $store_id => $val) {
   if (Mage::app()->getStore($store_id)->getName() == 'English') { // or whatever your store name is
     $variables = $english_variables;
     $variables = $german_variables;
   foreach ($variables as $key => $value) {
     $product->setStoreId($store_id)->setData($key, $value);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.