You are here:  » extra field mapping


extra field mapping

Submitted by george-p on Wed, 2016-05-25 15:00 in

Hello David

at my site i added extra field color

1) some feeds have colors like this "brown/black/green" or "brown|black|green" or "brown,black,green"...

how i can create sidebar filter for colors, and at filter have each color separate "brown", "black" , "green"
and not have colors like this "brown/black/green"

2) is possible like the brand mapping, to create mapping for colors ?

so for example i can map "light brown", "dark brown"... to brown

thanks!

Submitted by support on Thu, 2016-05-26 09:43

Hello George,

Regarding filters against fields containing a list of values, I have helped lots of users set this up but it is a bit tricky to describe as a mod so if you could email me search.php and html/searchfilters.php I'll add code for a colourFilter that works in this way..

Regarding custom field mapping, I have just very recently created an Admin extension that provides the same functionality as Category / Brand mapping but against any custom field, so I will forward that to you also...

Cheers,
David.
--
PriceTapestry.com

Submitted by shubi on Sun, 2022-02-13 19:02

Hey, first off impressive script, I am just getting to learn it, and seriously it is crazy powerful, great work. I was wondering if it possible to do this? my script is stil bare and I am right now playing with it. But I am looking to adding more features, on of them being this.

Submitted by support on Mon, 2022-02-14 08:50

Hello shubi,

Thank you for your comments.

There are instructions for adding custom fields in the first post in this thread...

All the best,

Cheers,
David.
--
PriceTapestry.com

Submitted by shubi on Mon, 2022-02-14 09:50

Thank you for the quick reply, the link is going to this thread, I think that is an error. But furthermore I have added the fields, but want it to be the same way as how brands, merchant and categories, so that as an example I can add it as a product filter in search like as an example if it's color it will be ?q=color:blue, and it will show the blue colour. Is that possible?

Submitted by support on Mon, 2022-02-14 10:18

Ooops, i've corrected the link!

Sure - you can add support for new search operators for custom fields easily; edit search.php and look for the following code beginning at line 127:

      case "brand":
        if ($config_useCategoryHierarchy)
        {
          $fields = array("merchant","brand");
        }
        else
        {
          $fields = array("merchant","category","brand");
        }

...and REPLACE with:

      case "brand":
      case "color":
        if ($config_useCategoryHierarchy)
        {
          $fields = array("merchant","brand","color");
        }
        else
        {
          $fields = array("merchant","category","brand","color");
        }

Cheers,
David.
--
PriceTapestry.com

Submitted by shubi on Mon, 2022-02-14 20:43

Awesome, thank you so much. It works perfectly. I was wondering if its possible to do it category specific? So if the category is MP3 player it shows colour filter but all other categries it doesnt?

Submitted by support on Tue, 2022-02-15 09:06

Hi,

This could be done in html/searchfilters.php, so where you would have added the new code for colorFilter it should begin (based on the code for the default filters) as follows;

      if ($parts[0] != "category")

...you could REPLACE with something like:

      $colorFilterCats = array("MP3 Players","Other Category 1","Other Category 2);
      if (($parts[0] == "category") && in_array($parts[1],$colorFilterCats))

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by shubi on Fri, 2022-02-18 18:21

Thank you so much, it is nearly working, but somehow it only works on categories.php but not in the search.php.

Submitted by support on Mon, 2022-02-21 11:48

Hi shubi,

Just to confirm, do you mean that if you enter directly in the search box:

category:MP3 Players

...the color filter does not show on the results page?

Cheers,
David.
--
PriceTapestry.com

Submitted by shubi on Mon, 2022-02-21 18:20

Yes, it doesn't show the color filter, but if I go to the category page and click the category instead it shows.

Submitted by support on Tue, 2022-02-22 09:02

Hello Shubi,

I may be mis-understanding sorry; can you confirm that you _only_ want the color filter to show for the category "MP3 Players" (and possibly other specific categories) but not for any other products?

Please could you copy the new section of code added to html/searchfilters.php for the colorFilter including the modifications suggested above so that I can see everything in context...

Thanks,
David.
--
PriceTapestry.com