1

I have a Low Search results page where I want to filter the results based on the presence of a value in one or more custom fields. In this case I am searching across two collections and I want to filter the results to only include entries where custom_field_1 OR custom_field_2 have a positive integer value.

{exp:low_search:results search:custom_field_1=">0" search:custom_field_2=">0" query="{segment_3}"}

However of course the tag above will only return entries where both fields are a positive integer, not one or the other.

The reason for doing this? I've populated an integer field in each of the channels I'm using with Expresso Store with a 1 or 0 using a custom extension that checks if a price is set. I thought this might be a neat way to be able to leverage Low Search with Store entries but alas, because I have multiple store channels I'm stumped at the last hurdle! Any ideas?

3

When I need to use LowSearch with Store I usually also use Solspace PreParse in that channel too. To set this up you will need to do a few steps.

  1. Create an additional textarea field in your field group store_detailes_parsed make sure that it searchable.
  2. Create an additional template in your partials/embeds folder _partials/store_search
  3. In the newly created template you will want to have something along the lines of:

    {exp:channel:entries entry_id="{preparse_entry_id}"}
    {!-- assuming your store field is called store_details --} {!-- we dont need to have the form or javascript in most cases --} {exp:store:product disable_form="yes" disable_javascript="yes"} {!-- Now we need to output anything that we might want to make searchable like price or product variations --}

    {if on_sale}{sale_price}{if:else}{regular_price}{/if} {!-- in Store 2.x the sale price is not set in the channel entry so be careful because preparse will only update when the entry is saved again. --}

    {!-- output the modifiers so they are also searchable and the --} {modifier_options} {option_name} {price_inc_mod}{!-- show value for each option --} {modifier_options}

    { any other fieldtype items you want } {/exp:store:product} {/exp:channel:entries}

  4. Goto Add-ons > Extensions > PreParse and select the channel of your Store field and then the name of your custom field for Store. This should refresh the right content area you will want to select your newly created store_details_parsed field and the _partials/store_search respectively.

  5. Save and repeat for each additional channel.

  6. Now you will need to modify your LowSearch Collections to use also search your newly created field.
  7. Rebuild your search indexes.

Now you should be able to preform a search form the front-end of the site and have Store specific details be populated in the search. If you wanted to provide a bit more control you could only output the price into one field and the variations into another custom field and the sale price into yet another field. You would just need to repeat the steps 1-4 again but instead of selecting the store_details each time you would need to select a different custom field. This should work without an issue because you are not using the {prepare_data} variable in the PreParse templates.

| improve this answer | |
  • Yep, either this or a custom filter using Low Search's hooks or its (still undocumented) filter API would be the way to go. – Low Aug 27 '14 at 8:33
  • The above doesn't really solve my problem - but thanks for the verbose write up Justin :) – Nathan Pitman Aug 28 '14 at 6:44
  • The real issue I need to overcome is being able to determine in a Low Search result which entries have prices defined in Store. This isn't so hard to achieve using the method you outline if Store uses just one channel, my problem arises from the fact that I have Store entries spanning multiple channels. @Low - I'll take a look at the hooks but any 'rough' guidance on the filter API would be super. :) – Nathan Pitman Aug 28 '14 at 6:47
  • @NathanPitman drop me an email for some rough guidance. :) – Low Aug 28 '14 at 10:16

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.