title: Magento - Set product attribute to use default values
body: <p>This has been asked many times before but with no working answer.</p>
  
  <p>I have multiple stores and some attributes have been overridden. I want to change these attributes to 'use default value' with a script.</p>
  
  <p>Here is an image showing store views and 'use default value' checkboxes
  <a href="http://dl.dropbox.com/u/3209649/storeviews-and-defaultvalues.png" rel="noreferrer">http://dl.dropbox.com/u/3209649/storeviews-and-defaultvalues.png</a> <em>(not allowed to post images yet)</em></p>
  
  <p>In <strong>app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php</strong> setData() is used with <strong>false</strong> for the second argument when 'Use Default Value' has been selected for any attributes.</p>
  
  <pre><code>/**
   * Check "Use Default Value" checkboxes values
   */
  if ($useDefaults = $this-&gt;getRequest()-&gt;getPost('use_default')) {
      foreach ($useDefaults as $attributeCode) {
          $product-&gt;setData($attributeCode, false);
      }
  }
  </code></pre>
  
  <p>The following code attempts to set the 'name' attribute to 'use default values' for product 1 in store 3 using the same method.</p>
  
  <pre><code>require_once '../app/Mage.php';
  Mage::app(3);
  
  $product = Mage::getModel('catalog/product')-&gt;load(1);
  
  $product-&gt;setData('name', false); # as used in ProductController.php
  $product-&gt;save();
  </code></pre>
  
  <p>Using </p>
  
  <pre><code>$product-&gt;setData('name', 'anything');
  </code></pre>
  
  <p>correctly sets the 'name' attribute to 'anything' but <strong>false</strong> does not set it to 'use default value'</p>
  
  <p>'Use Default Value' is not stored anywhere in the database so within the controller for the admin interface there must be another procedure that deletes the attribute row?</p>
  
  <p>Related Links here -> <a href="http://pastebin.com/raw.php?i=j7fwu9H6" rel="noreferrer">http://pastebin.com/raw.php?i=j7fwu9H6</a>
  (not allowed to post links yet either)</p>