[wellwell-devel] [SCM] Interchange wellwell catalog branch, master, updated. 8bb6e91ac695019bf7e689cbacd0bf6c4bb220f2
Stefan Hornburg
racke at rt.icdevgroup.org
Mon Jun 22 19:23:27 UTC 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Interchange wellwell catalog".
The branch, master has been updated
via 8bb6e91ac695019bf7e689cbacd0bf6c4bb220f2 (commit)
from c1e20a06489799c4bb0bad113fd77e061f1da390 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8bb6e91ac695019bf7e689cbacd0bf6c4bb220f2
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Mon Jun 22 21:22:49 2009 +0200
added [category-update] to add/change categories of a product
-----------------------------------------------------------------------
Summary of changes and diff:
code/category_update.tag | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
create mode 100644 code/category_update.tag
diff --git a/code/category_update.tag b/code/category_update.tag
new file mode 100644
index 0000000..aabfe5a
--- /dev/null
+++ b/code/category_update.tag
@@ -0,0 +1,45 @@
+UserTag category_update AddAttr
+UserTag category_update Routine <<EOR
+sub {
+ my ($opt) = @_;
+ my ($sku, $type, @category);
+
+ $sku = $opt->{sku};
+ $type = $opt->{type};
+
+ if (ref $opt->{category} eq 'ARRAY') {
+ @category = @{$opt->{category}};
+ }
+ elsif ($opt->{category}) {
+ $category[0] = $opt->{category};
+ }
+
+ $Tag->perl({tables => 'product_categories'});
+
+ my ($set, %oldcats, $code, $instr);
+
+ # get existing categories
+ $set = $Db{product_categories}->query(q{select category from product_categories where sku = '%s' and type = '%s'}, $sku, $type);
+ for (@$set) {
+ $oldcats{$_->[0]} = 1;
+ }
+
+ # determine new categories
+ for (@category) {
+ $code = $Tag->category_master($_, $code, $type);
+ }
+
+ if ($code) {
+ delete $oldcats{$_->[0]};
+
+ $Db{product_categories}->query(qq{insert into product_categories values('%s', %s, '%s')}, $sku, $code, $type);
+ }
+
+ # delete categories which are no longer used
+ if (keys %oldcats) {
+ $instr = join(',', keys %oldcats);
+
+ $Db{product_categories}->query(qq{delete from product categories where sku = $sku and category in ($instr)});
+ }
+}
+EOR
hooks/post-receive
--
Interchange wellwell catalog
More information about the wellwell-devel
mailing list