title: Magento - How to create attribute programmatically that can be used in 'Sort by'
body: <p>I need to programmatically create several attributes.</p>
  
  <p>Here is a part of my upgrade script  :</p>
  
  <pre><code>$dataOrder = array(
      'attribute_set'           =&gt; 'Main',
      'group'                   =&gt; 'Datawarehouse',
      'type'                    =&gt; 'int',
      'input'                   =&gt; 'text',
      'label'                   =&gt; 'Total order quantity',
      'global'                  =&gt; Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
      'required'                =&gt; 0,
      'comparable'              =&gt; 0,
      'searchable'              =&gt; 0,
      'unique'                  =&gt; 0,
      'user_defined'            =&gt; 1,
      'visible_on_front'        =&gt; 1,
      'visible'                 =&gt; 1,
      'is_filterable'           =&gt; 1,
      'used_for_sort_by'        =&gt; 1,
      'used_in_product_listing' =&gt; 1,
  );
  </code></pre>
  
  <p>My script works fine, all my attributes are created but I can't see them in the <code>Sort by</code> dropdown (frontend). In back office I can see my attributes, I can assign a value, all good.</p>
  
  <p>But under <code>Catalog -&gt; Manage Attributes -&gt; Properties -&gt; Frontend properties</code> : Used for Sorting in Product Listing is set to 'No'.</p>
  
  <p>I thought that <code>used_for_sort_by</code> and <code>used_in_product_listing</code> would be enough but looks like it's not.</p>
  
  <p>How can I set it to yes, without having to change it in the back office? Either by adding some lines in my upgrade script or by adding some code somewhere else.</p>
  
  <p><strong>EDIT</strong> I just realized that it's not only Used for Sorting in Product Listing that is not updating the right way. Everything below <code>required</code> isn't updating the way it should be, everything is set to 'No'.</p>