0

I have this working in advanced search :

catalogsearch/advanced/result/?name=vanille&is_bio=1

Every product whose name contains "vanille" and attribute "is_bio" set to true will appear.

Now since I need to search not just in "name" but also other fields like "brands", I have to use quick search and its "q" query (correct me if I'm wrong). But in this case attributes won't have any effect :

catalogsearch/result/?q=vanille&is_bio=1

Will show every products containing "vanille" whatever the value of "is_bio".

Is there anyway to activate params in quick search ?

1
  • Create your custom controller with custom filter. What is your search engine ? Feb 24, 2017 at 19:07

1 Answer 1

2
+100

Yes you can do this. You need to go Catalog > Attributes > Manage Attributes and locate your attribute. Make sure the configuration for Use in Search Results Layered Navigation is set to Yes:

Screenshot of attribute configuration

However, note the warning underneath the option:

Can be used only with catalog input type Dropdown, Multiple Select and Price.

This means that if you are currently using a Yes/No attribute type you will need to create a new Dropdown type attribute.

Once you have your attribute set to be used in layered navigation, you can then use it as a filter in your URL, e.g. catalogsearch/result/?q=vanille&is_bio=123 (where 123 is your "Yes" attribute option ID).

There is a caveat to changing from Yes/No to the Dropdown type. If you are using this attribute elsewhere in your codebase, you will no longer be able to use the getIsBio() method to test for true/false:

if ($product->getIsBio()) {
    // won't work for Dropdown types
}

if ($product->getAttributeText('is_bio') === 'Yes') {
    // works for Dropdown types
}
6
  • Question is for magento 1.9 Feb 25, 2017 at 7:38
  • @GopalPatel thanks for the heads up! Have updated my answer. Feb 25, 2017 at 7:54
  • question is regarding catalog search and your answer providing information on b=navigation filters. is_bio is working in advance search means it is searchable attribute. Feb 25, 2017 at 8:00
  • 1
    @GopalPatel Layered navigation can be used to filter catalog search results. Advanced search is a completely different configuration to layered navigation. Feb 25, 2017 at 8:05
  • Upps sorry got confused between my current project's requirement and this question Feb 25, 2017 at 8:10

Your Answer

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

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