Unfortunately, none of the efficient ways to update a product attribute work in this case. $product->getResource()->saveAttribute()
updates the attribute for all store views even if you set the store ID on the $product
object. Mage::getSingleton('catalog/product_action')->updateAttributes()
only updates the value in a specific store, but it cannot set the attribute to use the default value (see also this Stack Overflow question for a reference). Hence, we have to use the slow, memory intensive way via $product->save()
.
I assume that you know which attributes you would like to update. For the following example, I set the visibility
attribute to use the default value. The following script should then do the trick (make sure you change it according to your needs):
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once 'app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
set_time_limit(0);
function useDefaultValueCallback($args)
{
// change to the ID of your french store view
$specificStoreViewId = 7;
$product = Mage::getModel('catalog/product');
$product->setData($args['row']);
$product->setStoreId($specificStoreViewId);
// change according to your needs
$product->setData('visibility', false);
$product->save();
}
$products = Mage::getModel('catalog/product')->getCollection();
Mage::getSingleton('core/resource_iterator')->walk($products->getSelect(), array('useDefaultValueCallback'));