Home FAQ Back

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{ <BR><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%"> <TR><TD __HEADERBG__> <FONT SIZE="-1" COLOR="__HEADERTEXT__"> Customers who bought this item also bought: </TD> </TR><TR> <TD><FONT SIZE="-1"> }; for(@ary) { my $desc = tag_data( 'products', 'description', $_); $out .= q{<A HREF="[area $_]">$desc</A><BR>} } return $out . '</TD></TR></TABLE>'; [/perl] [/if-item-data]

This code is used in the barry and possibly other demos.



Interchange - © 2000 Akopia, Inc.