You are here:  » Include Merchant, Category and Brand into serach result

Support Forum



Include Merchant, Category and Brand into serach result

Submitted by fstore on Sat, 2011-08-06 12:37 in

Hi David
Currently my search only looks for product titles.

Can I enhance this so if i enter merchant name in search box, I return products from that Merchant?

I would also like it to work same way for Brand Name and Category Name.

I would appreciate if you could provide me the code.

thanks

Hassan

Submitted by support on Sat, 2011-08-06 16:47

Hello Hassan,

Yes this is easy to do.

First of all, you need to disable the full text index by changing line 8 of config.advanced.php as follows;

  $config_useFullText = FALSE;

Next, in search.php, look for the following code at line 229:

  $where .= "search_name LIKE '%".database_safe($word)."%'";

...and REPLACE with:

  $where .= "search_name LIKE '%".database_safe($word)."%'";
  $where .= "OR merchant LIKE '%".database_safe($word)."%'";
  $where .= "OR category LIKE '%".database_safe($word)."%'";
  $where .= "OR brand LIKE '%".database_safe($word)."%'";

Cheers,
David.
--
PriceTapestry.com

Submitted by fstore on Sun, 2011-08-07 12:29

Worked Perfectly!

Thanks

Submitted by fstore on Thu, 2012-04-12 06:11

David
How can I implement the same for my PT-wordpress-plugin site?

updating the same files as mentioned above will work? or I will need to update the files under wp-content/plugins/pto?

Regards
Hassan

Submitted by fstore on Thu, 2012-04-12 07:13

On my site I am not using the PT search form but instead I am using the wordpress theme search box.

Therefore I removed the search form code under Setting>PriceTapestry.org
and added the following code on wordpress theme searchform.php

can you please suggest how can I update the following code to enable search for product name/merchant/brand/? I have already updated the main PT files as described above post.

<form method='get' class='searchform' action='<?php echo home_url(); ?>/shopping/' onsubmit='this.submit();return false;'>
<fieldset>
<input type="text" value="<?php _e('Search','pagelines');?>" name='pto_q' class="searchfield" onfocus="if (this.value == '<?php _e('Search','pagelines');?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('Search','pagelines');?>';}" />
<input type="image" class="submit btn" name="submit" src="<?php echo PL_IMAGES;?>/search-btn.png" alt="Go" />
</fieldset>
</form>

Submitted by support on Thu, 2012-04-12 08:59

Hi Hassan,

To make the equivalent modification in the plugin, look for the following code at line 270 of pto_search.php:

  $where .= "search_name LIKE '%".$wpdb->escape($word)."%'";

...and REPLACE with:

  $where .= "search_name LIKE '%".$wpdb->escape($word)."%'";
  $where .= "OR merchant LIKE '%".$wpdb->escape($word)."%'";
  $where .= "OR category LIKE '%".$wpdb->escape($word)."%'";
  $where .= "OR brand LIKE '%".$wpdb->escape($word)."%'";

Don't forget to make sure that in wp-admin > Settings > PriceTapestry.org the drop down next to $config_useFullText is set to False...

Cheers,
David.
--
PriceTapestry.com

Submitted by fstore on Thu, 2012-04-12 10:34

David
I have applied these changes but its still not working.

For example I enter merchant name in search box "Games101" which return only 10 products.
But this merchant has 4111 products in my database and when I goto the merchant page (site.com/merchant) and click on "Games101" it does show 4111 products.

Also when I enter merchant name "Abit Computers" it doesn't return any product which belongs to them.

I have also activate the default PT plugin search box, but same results.

Any suggestion, thanks

Submitted by support on Thu, 2012-04-12 10:46

Hello Hassan,

I just double-checked the mod on my test server and it worked fine - can you confirm that the PriceTapestry.org setting for $config_useFullText has been set to False on wp-admin > Settings > PriceTapestry.org?

Cheers,
David.
--
PriceTapestry.com

Submitted by fstore on Thu, 2012-04-12 10:58

Yes David
it is set to false.

Please have a try on my site.

when you click on merchant name "ABIT Computers" on zeesh.com.au/merchant you get over 4000 products.
(See {link saved})

But when search "Abit Computers" in search box it only bring 5 product which belongs to some other merchant.
(See {link saved})

Regards
Hassan

Submitted by support on Thu, 2012-04-12 13:02

Hello Hassan,

Please could you make the following debug mod to pto_search.php by looking for the following code at line 348:

  return $html;

...and REPLACE with:

  $html .= "[".$sql."]";
  return $html;

...perhaps if you could let me know by email once it's online and attach your modified version at the same time that will be the quickest way...

Cheers,
David.
--
PriceTapestry.com