title: Update qty in php but not updated in Magento?
body: <p>I've got this code below to retrieve and update 1 of the SKU of my Magento product.</p>
  
  <p>It's updated and looks alright when I view on the code $product->getQty();</p>
  
  <p>But when I look into Magento, the qty was not updated....</p>
  
  <p>Could you please let me know where did I go wrong?</p>
  
  <pre><code>&lt;?php
  
      define('MAGENTO_ROOT', dirname(__FILE__));
      $mageFilename = MAGENTO_ROOT . '/app/Mage.php';
      require_once $mageFilename;
  
      Varien_Profiler::enable();
      ini_set('display_errors', 1);
      umask(0);
  
      Mage::app();
      //get the collection filter the simple products &amp; join the cataloginventory/stock_item table
      $collection = Mage::getModel('catalog/product')-&gt;getCollection()-&gt;addAttributeToSelect('sku')-&gt;addAttributeToFilter('type_id', 'simple')-&gt;joinField(
          'qty',
          'cataloginventory/stock_item',
          'qty',
          'product_id=entity_id',
          '{{table}}.stock_id=1',
          'left'
      ) ;
      ?&gt;
      &lt;html&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;body&gt;
      &lt;table&gt;
      &lt;?php 
      foreach ($collection as $product) {
          if ($product-&gt;getSku() == "test123") {
          try
              {
                $product-&gt;setData('qty', 99);
                $product-&gt;save();
              }
          catch (Exception $e)
              {
                echo $e-&gt;getMessage();
              }
          }
          echo "&lt;tr&gt;&lt;td&gt;".$product-&gt;getSku()."&lt;/td&gt;&lt;td&gt; ".(int)$product-&gt;getQty()."&lt;/td&gt;&lt;/tr&gt;";
      };
  
  ?&gt;
  </code></pre>