title: How to add a category to Magento via Setup script?
body: <p>I actually can add a category via setup script, the thing is for some reason some of the fields doesn't get set properly. Here's is my code</p>
  
  <pre><code>$this-&gt;startSetup();
  Mage::register('isSecureArea', 1);
  
  $category = Mage::getModel('catalog/category');
  $category-&gt;setPath('1/2') // set parent to be root category
      -&gt;setName('Category Name')
      -&gt;setUrlKey('category-name')
      -&gt;setIsActive(0)
      -&gt;setIncludeInMenu(1)
      -&gt;setInfinitescroll(1)
      -&gt;setDisplayMode('PAGE')
      -&gt;setLandingPage($idToCmsBlock)
      -&gt;setPageLayout('anotherLayoutThanDefault')
      -&gt;setCustomUseParentSettings(0)
      -&gt;setCustomLayoutUpdate('&lt;reference name="head"&gt;&lt;action method="addCss"&gt;&lt;stylesheet&gt;css/somecss.css&lt;/stylesheet&gt;&lt;/action&gt;&lt;/reference&gt;')
  -&gt;save();
  $this-&gt;endSetup();
  </code></pre>
  
  <p>After running this script, I have a category created with all my value set in the EAVs table.
  However the Flat table will be missing displayMode, landingPage, pageLayout, customLayoutUpdate even if I re-index the flat table.</p>
  
  <p>The weird thing is that if I go in the admin, I can see all those fields properly set but if I go in my frontend most of those fields are ignored. I will have to go to the admin, unset those value and reset them for each of them to work properly.</p>
  
  <p>Also let say I use setEnabled(1), my category will be "enable" in the admin but not show up in the frontend.</p>
  
  <p>PS: I have Flat Category activated, if I disable it seems to work fine but if I re-index it still not working.</p>