You are here:  » Apply filter on field once and use the value multiple times

Support Forum



Apply filter on field once and use the value multiple times

Submitted by gregor on Mon, 2012-11-26 05:30 in

Hi David, I'm sure I've seen this discussed before but I can't find the topic. Sometimes I have a field in the products table that includes several different fields from the merchant feed. I use %CATEGORY% for example, to add the category to the end of the description using a TextAfter filter. I might also include brand and a few other available fields from the feed and place them all at the end of the description. Then of course I'll use category, brand, etc. in their proper fields as well. Is there a way to apply a filter to the category value from the feed once, and then use that modified category value in several places. For example: I want to replace / with : in the category and then I want to save that value in the Category column and also add it to the end of the Description. Is there a way to do that? If I'm just combining two or three fields together I can usually work this out, but when I'm including 5 or 6 feed values into the same products table column it can become difficult. Are there some tricks to this or a mod that might help?

I seem to remember a 1-line mod that might help me with this, but I can't find it. Sorry :)

Thanks for any advice,
Gregor

Submitted by support on Mon, 2012-11-26 08:33

Hi Gregor,

It would be straight forward to fill $filterRecord (the array that is referred to when you reference another field using %FIELDNAME%. In includes/admin.php if you look for the following code at line 226:

  $importRecord[$filter["field"]] = $execFunction($filter["data"],$importRecord[$filter["field"]]);

...and REPLACE with:

  $importRecord[$filter["field"]] = $execFunction($filter["data"],$importRecord[$filter["field"]]);
  $filter_record[$admin_importFeed["field_".$filter["field"]]] = $importRecord[$filter["field"]];

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by gregor on Sat, 2012-12-01 23:46

I tried this today and it seems to work for global filters but not for feed level filters. I thought both types of filters were processed with the same code, so I don't know why this would be a problem. ??

I can add a filter to global filters for SKU and it will apply to all uses of that field. If I remove the global filter and add the same filter to the feed filter, it does not apply to the %SKU% value when used later. Any ideas?

Thank you,
Gregor

Submitted by support on Sun, 2012-12-02 12:20

Hi Gregor,

I wonder if this is due to sequencing - global filters are always applied first, followed by feed level filters, and in both cases in order of creation date, so this would explain it if the problem is that a feed level filter affecting, say, the SKU field is not seen by a global filter.

If you wanted to change the sequence so that feed filters are applied first, look for the following code in includes/admin.php at line 489:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."filters` WHERE filename='".database_safe($admin_importFeed["filename"])."' OR filename='' ORDER BY filename,created";

...and REPLACE with:

$sql = "SELECT * FROM `".$config_databaseTablePrefix."filters` WHERE filename='".database_safe($admin_importFeed["filename"])."' OR filename='' ORDER BY filename DESC,created";

Hope this helps!

Cheers,
David.
--
PriceTapestry.com