[ic] timed-build and discount tag

Music music at labyrinth.net.au
Fri Jul 3 01:24:42 UTC 2009


I am using a modified merchandising table to build a list of timed 
discounted items.

I then loop through the table and adjust pricing for all discounted items.

This works great and it allows us to apply discounted items with start and 
end dates. i.e. Discounted July 4th only.

However I am trying to set up caching of the discounted items using 
timed-build so we don't have to loop through and find the discounted items 
on every page load.


[comment]apply discounts and cache[/comment]
[timed-build file=discountcache reparse=1 force=1 minutes="10"]
        [query arrayref=main
                        SELECT sku,timed_promotion,start_date,finish_date
                        FROM merchandising
                        WHERE discount = 'discounted'
        [perl tables="merchandising"]
                my @out;
                my $ref;
                my $db;
                delete $Scratch->{promo_codes};
                my $date = $Tag->time( { body => '%Y%m%d' } );
                $ref = $Tmp->{main} or return;
                for(@$ref) {
                        my $line = $_;
                        push(@out, $line->[0]), next if ! $line->[1];
                        next if $line->[2] gt $date;
                        next if $line->[3] lt $date;
                        push @out, $line->[0];
                $Scratch->{promo_codes} = join(' ', @out);
        list="[scratch promo_codes]"

[discount [loop-code]] $s - $q * [loop-data merchandising 
<!--discounts applied [time]%k:%M%p[/time]-->

With the above code the cached file only includes the "discounts applied 
time' text (last line) and the list of discounted items appears as blank 

It all works perfectly if I remove the timed-build.

How do I get IC to write the list of discounted items to the cached file or 
is there another way of caching a loop of [discount] tags?

More information about the interchange-users mailing list