Build Related
Build Related
You can mine the data from your orderline database to suggest products that
might be bought in combination with a certain product.
All that is necessary is to access this page. The database will be mined and
entries made in the others_bought field of the merchandising database.
The database is scanned, and a list of items purchased on the same order with
each item is built. This is stored in a data structure and can be accessed
in a shopping cart or flypage with the code:
[if-item-data merchandising others_bought]
[perl tables=products]
my $hash = [item-data merchandising others_bought];
my @ary = sort { $hash->{$b} <=> $hash->{$a} } keys %$hash;
return '' unless @ary;
my %in_basket;
splice(@ary, 3);
for(@{$Carts->{main}}) {
$in_basket{$_->{code}} = 1;
}
@ary = grep ! $in_basket{$_}, @ary;
return '' unless @ary;
my $out = q{
Customers who bought this item also bought:
|
};
for(@ary) {
my $desc = tag_data( 'products', 'description', $_);
$out .= q{$desc }
}
return $out . ' | ';
[/perl]
[/if-item-data]
This code is used in the barry and possibly other demos.
Interchange -
© 2000 Akopia, Inc.
|