[interchange-bugs] [rt.icdevgroup.org #299] timed-build and discount tag
Stefan Hornburg via RT
interchange at rt.icdevgroup.org
Wed Jul 15 11:40:21 UTC 2009
Wed Jul 15 11:40:20 2009: Request 299 was acted upon.
Transaction: Ticket created by racke
Queue: Interchange
Subject: timed-build and discount tag
Owner: Nobody
Requestors: music at labyrinth.net.au
Status: new
Ticket <URL: http://rt.icdevgroup.org/Ticket/Display.html?id=299 >
Hi
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.
i.e.
[comment]apply discounts and cache[/comment]
[timed-build file=discountcache reparse=1 force=1 minutes="10"]
[query arrayref=main
sql="
SELECT sku,timed_promotion,start_date,finish_date
FROM merchandising
WHERE discount = 'discounted'
"][/query]
[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);
return;
[/perl]
[loop
list="[scratch promo_codes]"
]
[discount [loop-code]] $s - $q * [loop-data merchandising
discountminus][/discount]
[/loop]
<!--discounts applied [time]%k:%M%p[/time]-->
[/timed-build]
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
lines.
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-bugs
mailing list