5

I want to set sort order in attribute. In mysql file i m used this

  'sort_order' => 10

but it not worked

[Edit]

$installer->addAttribute('customer','badge', array( 
    'label'             => 'Badge',
    'type'              => 'text',    //backend_type
    'input'             => 'multiselect', //frontend_input
    'backend'           => 'eav/entity_attribute_backend_array',    
    'global'            =>  Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'source'            => 'marketplace/eav_entity_attribute_source_badge', // Goes to Step 2
    'visible'           => true,
    'required'          => false,
    'default'           => '',
    'frontend'          => '',
    'unique'            => false,
    'note'              => '',
    'sort_order'        => 10

));
Mage::getSingleton('eav/config')
    ->getAttribute('customer', 'badge')
    ->setData('used_in_forms', array('customer_account_create','customer_account_edit','customer_address_edit','checkout_onepage_register','checkout_onepage_register_guest','checkout_onepage_billing_address','adminhtml_customer','checkout_onepage_shipping_address','checkout_multishipping_register'))
    ->save();
4
  • we need a little bit more to work with to be able to help you. OF what entity/table you are trying to set this? Could you add the whole SQL query? WHAT doesn't work? What do you expect it to do? And what for/why? – 7ochem Mar 2 '15 at 8:30
  • I am add one attribute in customer attribute is created but in eav_entity_attribute table sort_order for this attribute is 0 but i want to change that so how to do that – ND17 Mar 2 '15 at 8:42
  • Could you post the whole query that you have tried already? – 7ochem Mar 2 '15 at 8:44
  • 'sort_order' works fine for me at least in EE1.13.1.0 – OZZIE Oct 12 '17 at 11:47
5

You have to use position instead of sort_order.

'position' => 20

From Mage_Customer_Model_Resource_Setup

/**
 * Prepare customer attribute values to save in additional table
 *
 * @param array $attr
 * @return array
 */
protected function _prepareValues($attr)
{
    $data = parent::_prepareValues($attr);
    $data = array_merge($data, array(
        'is_visible'                => $this->_getValue($attr, 'visible', 1),
        'is_system'                 => $this->_getValue($attr, 'system', 1),
        'input_filter'              => $this->_getValue($attr, 'input_filter', null),
        'multiline_count'           => $this->_getValue($attr, 'multiline_count', 0),
        'validate_rules'            => $this->_getValue($attr, 'validate_rules', null),
        'data_model'                => $this->_getValue($attr, 'data', null),
        'sort_order'                => $this->_getValue($attr, 'position', 0)
    ));

    return $data;
}
0
2

when you add attribute programmatically that time you have to set order like this

Mage::getSingleton('eav/config')
->getAttribute('customer', 'badge')
->setSortOrder(100)
 ->setData('used_in_forms', array('customer_account_create','customer_account_edit','customer_address_edit','checkout_onepage_register','checkout_onepage_register_guest','checkout_onepage_billing_address','adminhtml_customer','checkout_onepage_shipping_address','checkout_multishipping_register'))
->save();

'sort_order' is not worked

1
  • This is also worked – ND17 Mar 4 '15 at 8:49
1

The sort_order is the attribute that you need to change to move the attributes around the page. If the sort order is sequential then a simple trick to add some padding is to run the following command

UPDATE eav_entity_attribute SET sort_order = (sort_order*10) WHERE attribute_group_id = 4

Which will multiple each sort order by 10 allowing you to move the attributes around easier.

1
  • not worked. In that sort order is 0 – ND17 Mar 2 '15 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.