[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] mv_results and perl
Hello All,
I'm trying to refine search results manually with perl. From what I've
gathered during archive searches, $Search->{'mv_results'} is where the
search results are. WHat I would like to do is find all results that
match 0 in a column, and delete those from the array and pass it back so
that the new mv_results can be used farther on down the results page.
So I've written the following code into the results page, before the
[search-region] tag.
[perl table="products"]
my $s = $Search->{''};
return "No search passed." if ! $s;
my $ary = $s->{mv_results};
return "Bad search object." if ! $ary;
return "No match." unless @$ary;
my $out = 'Removed: ';
foreach $row (@$ary) {
my ($sku) = @$row;
# Get a field you didn't return in the search
$price = tag_data(products, dc_price, $sku);
if($price == 0)
{
delete $ary{$row};
}
}
$Search->{'mv_results'} = $ary;
return;
[/perl]
This always gives me nothing or something like ARRAY(KJHDF#$(&*)
I would also like to incorprate a counter decrementor for
Search->{'matches'} so that the number is decremented for each item removed.
I had originally tried using
[item-next][calc][item-price] eq "0"[/calc][/item-next]
But it didn't decrement the match number so on a search that originally
returned 25 matches of which say 7 were skipped. The more list would
still display "Matches 1-25"