You are here:  » Filters

Support Forum



Filters

Submitted by philstone on Sat, 2006-04-08 09:35 in

Hi Dave

is there a limit of how many filters you can have on any one product, 3 filters seems to do this to the link

eg.Toshiba-37WLT58--LCD--with-IDTV.html

when you click the link it doesn't work, but when you chnage filters so it only takes 2 it works no bother

regards

phil

Submitted by support on Sat, 2006-04-08 11:15

Hi Phil,

There isn't any set limit. Can you describe what filter settings you're using, and give an example of the original value, that should help us to see what's going on...

Thanks,
David.

Submitted by philstone on Mon, 2006-04-10 12:08

Hi Dave

Say there are 2 products

producta Plasma tv
productb Plasma

what would be the filters you would recommend using, i think because i am using both search and replace filters for both eg. "plasma tv" and "Plasma"

it means it creates a file producta--.html which doesn't exist, would iu be right in asuming this?

Regards

P Stone

Submitted by support on Mon, 2006-04-10 12:34

Ok, I see what's happening. You're correct - the result of search and replace (with nothing) on both "Plasma tv" and "Plasma" would result in a "URL safe" product name of "producta--" (for the first one) and "productb-" (for the second example).

However, on entry to search.php, the query first has all "-"'s converted into spaces; and is then trimmed; resulting in just "producta", for which there is no entry found because it is in the database as "producta " (the hypens are generated by the code that prepares a product name for use in a URL, they're not in the database).

I think the bese place to fix this is to modify the search and replace filter to trim the result before returning the modified value back to the import handler.

To do this; modify filter_searchReplaceExec() in includes/filters.php from:

<?php
  
function filter_searchReplaceExec($filter_data,$text)
  {
    return 
str_replace($filter_data["search"],$filter_data["replace"],$text);
  }
?>

to:

<?php
  
function filter_searchReplaceExec($filter_data,$text)
  {
    return 
trim(str_replace($filter_data["search"],$filter_data["replace"],$text));
  }
?>

That should fix it up after the next import...

Submitted by philstone on Mon, 2006-04-10 13:37

hi Dave

see in the filters, is there anyway that you could have a filter that cut out the text from before a symbol

eg

Zanussi ZCM930X / Dual Fuel Range Cooker

i only want

Zanussi ZCM930X so that it is compared with more merchants on one page, to save setting up filters for the whole feed could there be

Only text before/after option

then in the box i would just enter "/"

i tried the above adjustment, unfortunately it didn't work, kept coming up with -- and --- in the html address.

thanks for your help,

P Stone

Submitted by support on Mon, 2006-04-10 14:45

Hi Phil,

Just to confirm - you did re-import the affected feed after modifying the filter code...?

If you add the following block of code to the end of includes/filters.php, this will add a new filter "Split", which should do as you require - but there may be the odd syntax error as i've not tested this...!

<?php
  
/*************************************************/
  /* split                                         */
  /*************************************************/
  
$filter_names["split"] = "Split";
  function 
filter_splitConfigure($filter_data)
  {
    print 
"Split Character or String:<br />";
    print 
"<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
    
widget_errorGet("text");
  }
  function 
filter_splitValidate($filter_data)
  {
    if (!
$filter_data["text"])
    {
      
widget_errorSet("text","required field");
    }
  }
  function 
filter_splitExec($filter_data,$text)
  {
    return 
trim(substr($text,0,strpos($text,$filter_data["text"])));
  }
?>

Submitted by philstone on Mon, 2006-04-10 15:15

thanks for that dave

i did re-import the feeds a few times for the safe url problem - --.html , not sure what the problem may be

i tried the splitting code out, it doesn't seem to work

was wondering do i need to add "/" to the acceptable characters list to make that work? and if so where would i do that?

Regards

P Stone

Submitted by support on Mon, 2006-04-10 15:17

Of course - / is stripped before it reaches the filter....!

Ok, back to the drawing board on this one, bear with me....

Submitted by support on Mon, 2006-04-10 15:20

One option is to move the user filters infront of the standard filters in admin__importRecordHandler().

If you move the following code...

<?php
    
/* apply user filters */
    
$filter_dropRecordFlag false;
    if (
$admin_importFiltersExist)
    {
      foreach(
$admin_importFilters as $filter)
      {
        
$execFunction "filter_".$filter["name"]."Exec";
        
$record[$filter["field"]] = $execFunction($filter["data"],$record[$filter["field"]]);
      }
    }
?>

...above the line that says

<?php
  
/* apply standard filters */
?>

...then you should be able to process on the "/" character...

Submitted by philstone on Mon, 2006-04-10 15:47

Working now!!

split whole feed no problems, thanks dave. If you have any joy with the other filter issue let me know - your a star

Another wee thing, is there anyway to add the "brand" into the product name through the filter page using the text before method?

just would help match up a few more feeds if it was possible

thanks
Phil

Submitted by philstone on Tue, 2006-04-11 08:42

Hi dave

Wee Problem

imported my dixons feed, and had to reset the filters, but i got that done ok, but i am trying to add some "text after" to the description feed

the code i have typed in is

<br><b><p>Spend &pound;300 - &pound;25 Discount - Use Code ONLINE25.<br>Spend &pound;600 - &pound;50 Discount - Use Code ONLINE50.<br>Spend &pound;1500 - &pound;100 Discount - Use Code ONLINE100. <p>Use this Promotional code when buying this or any product from Dixons</b><br>This Discount has not been taken from the price column! <br><b>All Dixons Vouchers will Run until 31st May 06</b>

if you go to Here you will see whats happening, this only seems to have happened since i changed the admin.php file

Please could you have a wee look and advise me on what i should do to fix this

Regards

phil

ps The currys feed has not been reimported yet, thats why it shows the way the dixons one should show

Submitted by support on Tue, 2006-04-11 08:53

Hi Phil,

That's because the description is being "normalised" as part of the standard filters; and now, because of the changes you made yesterday, that is taking place after your additional code has been applied through the "Text After" filter.

In this case, I think the best thing to do is to remove the normalisation on the description field; and just keep a careful eye on your site to make sure that everything looks ok for you; as this will mean that HTML from the feed will make it onto your website.

Look for the following code in the admin__importRecordHandler() function in includes/admin.php:

<?php
    
if ($admin_importFeed["field_description"])
    {
      
$record[$admin_importFeed["field_description"]] = strip_tags($record[$admin_importFeed["field_description"]]);
      
$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!");
    }
?>

If you wish to preserve your additional HTML, I would simply comment out the above block of code and this will leave the description field unmodified.

Submitted by philstone on Tue, 2006-04-11 09:13

Thanks Dave

Again - Your a genius!!!

later

phil

Submitted by knight01 on Mon, 2008-03-17 17:23

David,
I've been commenting out the description and product name blocks as described above. It's worked well until I found a merchant who is insisting on using the # symbol in the product name. This gets passed into the url and causes all types of errors as the browser thinks its is looking for an anchor link.

I still would like to allow typical symbols in the name such as commas, periods and parentheses but I need to strip out the #. If I uncomment this

<?php
 $record
[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]]);
?>

then it strips all of the symobols. I've allowed them in the $q on top of search and product pages as such
<?php
 $q 
= (isset($_GET["q"])?tapestry_normalise($_GET["q"],"&:\.\/\(\)\+\,"):"");
?>
But of course they are getting stripped during import so it does not matter if I allow them since they are not there.

I guess I need to figure out how to allow periods, commas, parentheses and slashes in the name without allowing everything else.

Submitted by support on Tue, 2008-03-18 08:28

Hi,

You can make the characters you wish to permit be allowed in by changed the line that you have previously uncommented:

 $record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]]);

...as follows:

 $record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]],"&:\.\/\(\)\+\,");

That should match what you are allowing in through $q....

Hope this helps!
Cheers,
David.