将所有产品设置为使用所有商店的默认值

I have a Magento 1.5.0.1 install with 3 different store views. At some point along the way two of the stores dont use the default values for product attributes. I am trying to find a way to make all products use default values for all stores, that way the client only has to update things in one place. I found this article but it seems like it only applies to specifically called products. Can anyone explain how to employ that code in my situation? Or suggest new code?

The only way I could get this to work was via MySQL:

DELETE FROM `catalog_product_entity_text` where store_id != 0;
DELETE FROM `catalog_product_entity_datetime` where store_id != 0;
DELETE FROM `catalog_product_entity_decimal` where store_id != 0;
DELETE FROM `catalog_product_entity_int` where store_id != 0;
DELETE FROM `catalog_product_entity_varchar` where store_id != 0;

The above will reset all products to use default values for all attributes.

You should use the Mage::getSingleton('catalog/product_action') to update a lot of product in a row.

1°) Get the ids of product you want, for all product use :

$ids = Mage::getModel('catalog/product')->getCollection()->getAllIds();

2°) Make the list of the attribute and associate the value "false"

$attributes = array('name'=>false,'description'=>false,....)

3°) Pick up the list of store ids to change and set it in an array too :

$stores = array(1,2,3);

Then create your script :

foreach ($stores as $store_id)
{
     Mage::getSingleton('catalog/product_action')->updateAttributes($ids, $attributes, $store_id);
}

It will update all products (ids) to set the attributes to default (thanks to the "false" value) in the store_id.

This will take values that have been set on any store and merge those into the default values for all products:

     <?php 
    $cat = mysql_connect("host", "user", "password") or die(mysql_error());
        mysql_select_db("database",$cat) or die(mysql_error());

        $types = array(
        'catalog_product_entity_text',
        'catalog_product_entity_datetime',
        'catalog_product_entity_decimal',
    'catalog_product_entity_int',
    'catalog_product_entity_varchar'
    );

    foreach($types as $type){

    $result = mysql_query("select * from $type where store_id != 0",$cat) or die(mysql_error());  

        while ($row = mysql_fetch_assoc($result)) {

            if(!is_null($row['value'])){

                mysql_query("update $type set value = '".mysql_real_escape_string(stripslashes($row['value']))."' 
                where store_id = '0' 
                and entity_id = '".$row['entity_id']."' 
                and attribute_id = '".$row['attribute_id']."'",$cat) or die(mysql_error()); 
            }

            mysql_query("delete from $type where value_id = '".$row['value_id']."'",$cat) or die(mysql_error()); 

        }

    }
?>