1

I have added a couple of custom attributes to the catalog advanced search form, but they appear in the order you add them. With the last attribute added at the bottom of the form. I would like to change the order of form fields to make it a bit more intuitive for my visitors. How can I do this?

4
  • How did you added the attributes?
    – mbalparda
    Commented Aug 1, 2014 at 16:57
  • I added the attributes through Catalog > Attributes > Manage Attributes. And I set the property "Use in Advanced Search" to Yes.
    – Snels Nick
    Commented Aug 1, 2014 at 18:12
  • Have you tried to set the position field of the attribute? At the same page where you set "use in advanced search"?
    – Amasty
    Commented Aug 2, 2014 at 4:40
  • The position field is not editable. It is only editable when you use the attribute in Layered Navigation. And the field 'Use In Layered Navigation' is only editable with catalog input type Dropdown, Multiple Select and Price. And my catalog input type is a text area and text fields.
    – Snels Nick
    Commented Aug 2, 2014 at 8:33

1 Answer 1

1

The advanced form in the base template is in the file app/design/frontend/base/default/template/catalogsearch/advanced/form.phtml and it loads the attributes to show as part for a foreach loop.

It uses the function call Mage_CatalogSearch_Block_Advanced_Form::getSearchableAttributes to load the attributes. Which intern loads a collection of attributes with the filter use in advanced search but sadly only uses attribute id as the order.

->setOrder('main_table.attribute_id', 'asc')

I see you have two options:

  1. Extend Mage_CatalogSearch_Model_Advanced::getAttributes and set your own order in the collection. You could extend the attribute table to have a new column to order attribute by.
  2. Extend Mage_CatalogSearch_Block_Advanced_Form::getSearchableAttributes and perform some form of processing on the attributes so that they appear in the order that you desire.

For me option 1 would be the cleanest and you could extend the system so that the admin user could specify the order they want, but it would also be the most work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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