Revision a206d0be
Von Werner Hahn vor fast 9 Jahren hinzugefügt
SL/Controller/ShopPart.pm | ||
---|---|---|
my ($self) = @_;
|
||
|
||
my @categories = @{ $::form->{categories} || [] };
|
||
my $categories->{shop_category} = \@categories;
|
||
$main::lxdebug->dump(0, 'WH: KATEGORIEN: ', \@categories);
|
||
my @cat = ();
|
||
foreach my $cat ( @categories) {
|
||
# TODO das koma macht Probleme z.B kategorie "Feldsalat, Rapunzel"
|
||
my @temp = [split(/,/,$cat)];
|
||
push( @cat, @temp );
|
||
}
|
||
$main::lxdebug->dump(0, 'WH: KAT2:',\@cat);
|
||
|
||
my $categories->{shop_category} = \@cat;
|
||
|
||
my $params = delete($::form->{shop_part}) || { };
|
||
|
SL/ShopConnector/Shopware.pm | ||
---|---|---|
|
||
my $data = $self->connector->get("http://$url/api/categories");
|
||
my $data_json = $data->content;
|
||
$main::lxdebug->dump(0, 'WH: IMPORT', \$data_json);
|
||
my $import = SL::JSON::decode_json($data_json);
|
||
my @daten = @{$import->{data}};
|
||
my %categories = map { ($_->{id} => $_) } @daten;
|
||
... | ... | |
return \@daten;
|
||
}
|
||
|
||
sub get_article {
|
||
}
|
||
|
||
sub get_articles {
|
||
my ($self, $json_data) = @_;
|
||
$main::lxdebug->dump(0, 'WH: JSON: ', \$json_data);
|
||
|
||
}
|
||
|
||
... | ... | |
active => $shop_part->active,
|
||
images => [ @images3 ],
|
||
__options_images => { replace => 1, },
|
||
#categories => [ { name => 'Deutsch\test2' }, ], #[ $categories ],
|
||
categories => [ { path => 'Deutsch|test2' }, ], #[ $categories ],
|
||
|
||
)
|
||
;
|
||
... | ... | |
#my $delImg = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $del_imgString);
|
||
#update
|
||
my $upload = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $dataString);
|
||
my $data_json = $upload->content;
|
||
my $upload_content = SL::JSON::decode_json($data_json);
|
||
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);
|
||
return $upload_content->{success};
|
||
}else{
|
||
#upload
|
||
$main::lxdebug->message(0, "WH: else success: ". $import->{success});
|
||
my $upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
|
||
my $data_json = $upload->content;
|
||
my $upload_content = SL::JSON::decode_json($data_json);
|
||
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);
|
||
return $upload_content->{success};
|
||
}
|
||
|
||
}
|
templates/webpages/shop_part/categories.html | ||
---|---|---|
[% LxERP.t8("Part") %]: [% HTML.escape(SELF.shop_part.part.displayable_name) %]<br>
|
||
[% LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
|
||
<br>
|
||
[% Dumper.dump_html(SELF.shop_part.shop_category) %]
|
||
[% # Dumper.dump_html(SELF.shop_part.shop_category) %]
|
||
<br>
|
||
[% # Dumper.dump_html(CATEGORIES) %]
|
||
|
||
<form action="controller.pl" method="post">
|
||
[% BLOCK recurse %]
|
||
[% # path = '' %]<!-- TODO: Pfad wg neuer Kategorie im Shop anlegen -->
|
||
[% FOREACH obj = data %]
|
||
<ul>
|
||
<li>
|
||
[% checked = '' %]
|
||
[% IF SELF.shop_part.shop_category.grep(obj.name).size %]
|
||
[% # path = path _ obj.name %]
|
||
[% # test = path.split('\|') %]
|
||
[% # Dumper.dump_html(SELF.shop_part.shop_category.size) %]
|
||
[% IF SELF.shop_part.shop_category.1.grep(obj.name).size %]
|
||
[% checked = 'checked' %]
|
||
[% ELSE %]
|
||
[% FOREACH cat_row = SELF.shop_part.shop_category %]
|
||
[% IF cat_row.1.grep(obj.name).size %]
|
||
[% checked = 'checked' %]
|
||
[% END %]
|
||
[% END %]
|
||
[% END %]
|
||
[% L.checkbox_tag('categories[]',value=obj.name, checked=checked) %][% HTML.escape(obj.name) %]</li>
|
||
[% L.checkbox_tag('categories[]',value=obj.id _"," _ obj.name _ ",PFAD", checked=checked) %][% HTML.escape(obj.name) %]</li>
|
||
[% IF obj.childrenCount >= 1 %]
|
||
[% # path = path _ '|' %]
|
||
[% INCLUDE recurse data=obj.children %]
|
||
[% END %]
|
||
</ul>
|
||
... | ... | |
<!-- TODO: Is still hardcoded 'Root' is shopware specified -->
|
||
[% IF row.name == 'Root' %]
|
||
[% IF row.childrenCount >= 1 %]
|
||
[% INCLUDE recurse data=row.children %]
|
||
[% path = '' %]
|
||
[% INCLUDE recurse data=row.children path=path %]
|
||
[% END %]
|
||
[% END %]
|
||
[% END %]
|
Auch abrufbar als: Unified diff
Kategorien werden mit ID und Name in die DB geschrieben. Ein Komma im Name erzeugt noch Fehler. Der Pfad muss noch gemacht werden