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?
Magento – How to change the order of the form fields of the catalog advanced search form
advanced-searchmagento-1.9
Related Solutions
I had the same problem. I had to downgrade back to mysql 5.5 for it to work.
I narrowed the problem down to this query when searching by name which returns no results because it doesn't match the word:
select
e.*,
price_index.price,
price_index.final_price,
IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) as minimal_price,
price_index.min_price,
price_index.max_price,
price_index.tier_price,
cat_index.position as cat_index_position
from
catalog_product_entity as e
inner join
catalog_product_index_price as price_index
on (price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0)
inner join
catalog_category_product_index as cat_index on (cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id='2')
where
(e.entity_id IN
(SELECT
t1.entity_id
FROM
catalog_product_entity_varchar AS t1
LEFT JOIN
catalog_product_entity_varchar AS t2
ON t1.entity_id = t2.entity_id
AND t1.attribute_id = t2.attribute_id
AND t2.store_id=1
WHERE
(t1.store_id = 0)
AND
(t1.attribute_id = 60)
AND
(t1.entity_id = price_index.entity_id)
AND
(IF(t2.value_id>0, t2.value, t1.value) LIKE '%gift%')
)
);
Near the end the IF(t2.value_id>0, t2.value, t1.value) doesn't seem to return anything when t2.value_id and t2.value are NULL, if I change it to IF(t1.value_id>0, t1.value, t1.value), it worked.
You can construct the query that is being used for your advanced search by putting:
var_dump($this->getSearchModel()->getProductCollection());
die();
in getResultCount() from app\code\local\Mage\CatalogSearch\Block\Advanced\Result.php
Then looking in the _parts section
We studied such an option to allow multiple selection of filters while writing ElasticSuite.
The override should be in :
\Magento\CatalogSearch\Model\Layer\Filter\Attribute::_getItemsData() (URL Generation in which you should set value to the imploded value)
\Magento\CatalogSearch\Model\Layer\Filter\Attribute::apply (explode the value of the filter).
Then you need to fix the DI. Take cares it is located into the frontend area. You can read a full example here :
You may also encounter some SQL, SolR or ES problem to handle the array.
We have renounced to it since we do not use option ids but labels and it was a nightmare to handle multivalued this way. You can see the result here (looks likes your problem). : http://demo.magento-elastic-suite.io/index.php/women/tops-women.html?style_general%5B0%5D=Tee&style_general%5B1%5D=Pullover.
Hope it's help.
Best Answer
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.I see you have two options:
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.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.