Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Interchange: users

timed-build and discount tag

 

 

Interchange users RSS feed   Index | Next | Previous | View Threaded


music at labyrinth

Jul 2, 2009, 6:24 PM

Post #1 of 3 (695 views)
Permalink
timed-build and discount tag

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?









_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users


music at labyrinth

Jul 6, 2009, 4:29 AM

Post #2 of 3 (599 views)
Permalink
Re: timed-build and discount tag [In reply to]

> 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?

Perhaps if the discount tag could accept something like this:
[discount sku1 sku2 sku3 sku4 sku5]

it would make it easier to cache?



_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users


racke at linuxia

Jul 6, 2009, 11:55 PM

Post #3 of 3 (590 views)
Permalink
Re: timed-build and discount tag [In reply to]

Music wrote:
> 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?

That looks like a bug to me. The answer would be to fix this bug :-).

Regards
Racke



--
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team


_______________________________________________
interchange-users mailing list
interchange-users [at] icdevgroup
http://www.icdevgroup.org/mailman/listinfo/interchange-users

Interchange users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.