You are here:  » Product Tags (keywords) System


Product Tags (keywords) System

Submitted by keshavkshirsagar on Mon, 2016-07-25 05:14 in

Hi David

Can we Create Product Tags (keyword) System In PT

When user click on specific Tag all product will list related to selected tag
One Products May contains multiple tags or keywords
Which will be useful For optimize site

Good Day :)

Submitted by support on Mon, 2016-07-25 11:38

Hi,

If you first add a new custom field "tags" as per the standard instructions however instead of the usual VARCHAR(255), use a TEXT type instead, in other words a dbmod.php as follows;

<?php
  
require("includes/common.php");
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."feeds`
            ADD `field_tags` VARCHAR(255) NOT NULL"
;
  
database_queryModify($sql,$result);
  
$sql "ALTER TABLE `".$config_databaseTablePrefix."products`
            ADD `tags` TEXT NOT NULL"
;
  
database_queryModify($sql,$result);
  print 
"Done.";
?>

Import your comma separated tags field either from feeds, or to manage manually per product see this thread regarding additional custom fields as part of the Product Mapping functionality.

With that in place, you can now create a custom search handler using a LIKE clause against the `tags` field. To do this, edit search.php and look for the following code at line 230:

      case "bw":

...and REPLACE with:

      case "tag":
        $where = "tags LIKE '%".database_safe($parts[1])."%'";
        $sql = "SELECT SQL_CALC_FOUND_ROWS id,COUNT(id) AS numMerchants,MIN(price) as minPrice FROM `".$config_databaseTablePrefix."products` WHERE ".$where.$priceWhere." GROUP BY search_name";
        $orderBySelection = $orderByDefault;
        break;
      case "bw":

You'll then be able to link to search results for the tag "Widgets" using, for example;

http://www.example.com/search.php?q=tag:Widgets

Cheers,
David.
--
PriceTapestry.com

Submitted by keshavkshirsagar on Mon, 2016-07-25 12:01

Thanks David