[ic] Custom SearchOP

Tom Tucker tom at ttucker.com
Sun Sep 9 22:58:25 EDT 2007

Mac OS X 10.4.10
Interchange 5.4.0 (Tried with both Low and High Traffic settings)
Perl 5.8.6 threaded (PERL_SIGNALS="unsafe" set in the ENV)
MySQL 5.0.27-standard

Never had a problem starting daemon and no other odd behavior that I 
have seen.

I have implemented the following Custom SearchOp according to the 
instructions in the list and docs (I think ):

I have a column in my database, 'model', that can contain a comma 
separated list of model years for which a particular part is applicable. 
For example:

I need to be able to search on three fields, prod_group, model and category.

When I use a search of the form:

I get some products returned, but not the list I would expect. I added 
the ::logDebug statement but don't get any output in the debug.log file. 
In fact when I deliberately put in an error in SearchOp perl routine, I 
don't even get an error message on catalog restart.

## Custom search op for model years. Takes a comma
## separated list of individual 2 digit model years
## or a range, ex: 55,63,65-68,70-73 and will
##  determine if the search expression matches
##  specifically or falls within the range.
CodeDef modelyr  SearchOp
CodeDef modelyr  Routine <<EOR
sub modelyr {
  my ($self, $i, $pat) = @_;
::logDebug("modelyr: testing $self against $pat");

  return sub {
    my $this = shift;
    my @pat = split(/,/, $pat);
    #print "  subtesting $this ";
    foreach my $that ( @pat ) {
      # Check to see if matches in a range of model years
      if ( $that =~ /-/) {
        my ($strt, $end) = split(/-/, $that);
        #print "against $strt thru $end\n";
        return 1 if ($this >= $strt && $this <= $end);
      # Check to see if matches a single model year
      #print "against $that\n";
      return $this == $that;

Any assistance greatly appreciated.

Tom T.

More information about the interchange-users mailing list