Products module - search action help needed

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Products module - search action help needed

Post by Cerulean »

I'm loving the Products module - it seems really powerful.

I have a couple of questions regarding the "search" action of the module:

1. How do you create a field in the search form to search by Category or combinations of Categories? The sample search template shows how you can add controls for a number of different criteria including Field Definitions (custom fields), but I can't see how to add Categories to the search form.

2. The sample search template shows how to add controls for Text-type and Dropdown-type Field Definitions (custom fields) to the search form, but how do you add Checkbox-type or other types to the search form?

Thanks.
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Products module - search action help needed

Post by Cerulean »

Anyone?
Categories are pretty fundamental to this module - there's gotta be a way to get them into the search form, isn't there?
vigor
Forum Members
Forum Members
Posts: 92
Joined: Sat Apr 25, 2009 2:32 pm

Re: Products module - search action help needed

Post by vigor »

Did you figure out how to include the categories into your search?

I have thought about adding in a custom dropdown field called category and using this as my category but their has to be a way to use the standard category feature in your search.

Thanks,
Paul
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Products module - search action help needed

Post by Cerulean »

No, I haven't found a solution to this yet.
CTLModuleMaker is an alternative module to consider - it has a search function too.
henson
Forum Members
Forum Members
Posts: 20
Joined: Mon Sep 17, 2007 11:17 pm
Location: UK

Re: Products module - search action help needed

Post by henson »

Hey Cerulean,

I have been searching everywhere for a way to add my custom fields to the search criteria (in essence I am trying to create an "Advanced Search" form) and noticed that you said:
The sample search template shows how you can add controls for a number of different criteria including Field Definitions (custom fields)
The sample search template that I have doesn't seem to have this info in it and I really am struggling to get any of my Custom fields to show up in the searches.

Have you any ideas?

Marc
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Products module - search action help needed

Post by Cerulean »

Henson, I wish I could help more, but I struggled with the products module and now the project I was going to use it in is on hold so I haven't made any further progress.

You'll see I said:
2. The sample search template shows how to add controls for Text-type and Dropdown-type Field Definitions (custom fields) to the search form, but how do you add Checkbox-type or other types to the search form?
So the sample template is only useful if the Field Definitions you have added are Text-type or Dropdown-type. And having said that, I just tested the two text-type options of "Text input" and "Text area" and they didn't appear in the search box so I don't know what's up there.
EDIT: they do appear, but as empty dropdown boxes. To fix this, in the code from the sample template below, change {if $obj->type == 'text'} to {if $obj->type == 'textbox'} or {if $obj->type == 'textarea'}

Here is the relevant code from the sample template:

Code: Select all

{if isset($searchprops)}
{foreach from=$searchprops key='propname' item='obj'}
<div class="row">
  <p class="row_prompt">{$obj->prompt}:</p>
  <p class="row_input">
    {if $obj->type == 'text'}
      <input type="text" name="{$actionid}cd_propvalue[{$propname}]" size="40" maxlength="40"/>
    {else if $obj->type == 'dropdown'}
      <select name="{$actionid}cd_propvalue[{$propname}]">
      {html_options options=$obj->options}
      </select>
    {/if}
  </p>
</div>
{/foreach}
{/if}
It would be great if Calguy could give us some help here.
Last edited by Cerulean on Fri Sep 16, 2011 5:00 am, edited 2 times in total.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Products module - search action help needed

Post by applejack »

Why not just use the search module and restrict it to just searching the Products module as this will search all data in Products.
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Products module - search action help needed

Post by Cerulean »

Applejack, I'm not sure if your suggestion was directed to me or henson, but in my case the objective was to create an "Advanced Search" where a user can find products in Category 1 AND Category 4, or with Custom Field 1 AND Custom Field 2, etc.

The usefulness of categories and custom fields in this module is greatly diminished by the fact that there is no documented way of including them in a search.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Products module - search action help needed

Post by applejack »

You cannot search more than one custom field at a time. I recently need to do this myself on a project and asked Calguy who said he would do this as a paid job to which I agreed to the fee and then never heard back from him.

You can search multiple categories and hierarchies though.

There are ways of hacking the search to return results from multiple custom fields by using conditional statements within the foreach loop but it can get complicated and you need to write your own pagination routine. Just depends what exactly you need to be able to do.
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Products module - search action help needed

Post by Cerulean »

You can search multiple categories and hierarchies though.
Do you mean by using the normal CMSMS {search} module?

The problem with this is that the user only has a text search field and isn't going to know what categories are available.
Or is it possible to create a more advanced search with the {search} module that uses dropdowns or checkboxes?
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Products module - search action help needed

Post by applejack »

No not using the search module or the search option of the products module. Using drop downs or checkboxes.

I have only done this using custom fields and the using the fieldlist action to populate the drop downs but I think you can also do this for categories. So say you have your drop downs and then you point the form action to a specific page and then you capture each value selected from the drop downs and then pass them to the summary action in the call to the Products module. So in the page content block or template you have i.e. (fieldid='4' the number relates to the custom field id you wish to search)

Code: Select all

{if $smarty.post.dropdown_value_1 || $smarty.post.dropdown_value_2}
	{assign var=dropdown_value_1 value=$smarty.post.dropdown_value_1}
	{assign var=dropdown_value_2 value=$smarty.post.dropdown_value_2}
	{capture assign=collect}{Products fieldid='4' fieldval="$dropdown_value_1" sortorder='asc' summarytemplate='collection' category="$dropdown_value_2" pagelimit='12'}{/capture}
	{if $collect}
		{$collect}
	{else}
		No Results Found for "{$smarty.post.dropdown_value_1} or {$smarty.post.dropdown_value_2}"
	{/if}
{/if}
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am
Location: New Zealand

Re: Products module - search action help needed

Post by Cerulean »

Thanks for sharing your code, applejack.

I'll be sure to give it a try in my project when it gets underway.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Products module - search action help needed

Post by applejack »

No problem. Any other questions about this just ask.
JM6891
Forum Members
Forum Members
Posts: 150
Joined: Thu Mar 18, 2010 2:35 pm

Re: Products module - search action help needed

Post by JM6891 »

I'm also looking to create an advanced search form for products but I'm struggling to understand how to amend the default search form template to search through my field definitions.

For example I have the following field definitions that I'd like the user to be able to filter:

- Model / Reference Number
- Price (which is already in the template)
- New / Used
- Capacity

All of the above would be drop downs apart from the model / ref number and would work in the same way to Price. The model / ref number in the search form would be text input.

Can anyone offer any help or point me in the right direction to a tutorial? I've searched for a tutorial but couldn't find anything and the module help section doesn't have information on this either.

Thanks in advance
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Products module - search action help needed

Post by applejack »

You can only search ONE custom field. It is because of the way the DB is set up and so the help documentation is wrong. I have tried and I know for sure it doesn't work. The only work around is to use conditional statements in the foreach loop of a summary template but this can get very complicated depending upon the number of search options.

So either set up your products structure using categories and hierarchies and one searchable custom field or ask Calguy to re-write it and see if he ever gets back to you.
Post Reply

Return to “Modules/Add-Ons”