title: magento programmatically add more custom options
body: <p>I would like programmatically create product with more then one custom option. My current code is bellow but only last option is saved. Can anyone help?</p>
  
  <pre><code>$options = array(
          array(
              'is_delete' =&gt; 0,
              'title' =&gt; 'First Line',
              'type' =&gt; 'text',
              'is_require' =&gt; 0,
              'sort_order' =&gt; 1,
          ),
          array(
              'is_delete' =&gt; 0,
              'title' =&gt; 'Second Line',
              'type' =&gt; 'text',
              'is_require' =&gt; 0,
              'sort_order' =&gt; 2,
          )  
  );
  
  $product = Mage::getModel('catalog/product')-&gt;load($id);
  $optionInstance = $product-&gt;getOptionInstance();
  
  foreach($options as $option){
  
      $product-&gt;setHasOptions(1);
  
      if (isset($option['is_require']) &amp;&amp; ($option['is_require'] == 1)) {
          $product-&gt;setRequiredOptions(1);
      }
  
      $optionInstance-&gt;addOption($option);
      $optionInstance-&gt;setProduct($product);
      $product-&gt;save();
  }
  </code></pre>