Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a206d0be

Von Werner Hahn vor mehr als 8 Jahren hinzugefügt

  • ID a206d0beed0268483e1fb436bfa62d86d3d05b6c
  • Vorgänger 4edf2b76
  • Nachfolger 8c73a980

Kategorien werden mit ID und Name in die DB geschrieben. Ein Komma im Name erzeugt noch Fehler. Der Pfad muss noch gemacht werden

Unterschiede anzeigen:

SL/Controller/ShopPart.pm
156 156
  my ($self) = @_;
157 157

  
158 158
  my @categories =  @{ $::form->{categories} || [] };
159
  my $categories->{shop_category} = \@categories;
159
  $main::lxdebug->dump(0, 'WH: KATEGORIEN: ', \@categories);
160
  my @cat = ();
161
  foreach my $cat ( @categories) {
162
    # TODO das koma macht Probleme z.B kategorie "Feldsalat, Rapunzel"
163
    my @temp = [split(/,/,$cat)];
164
    push( @cat, @temp );
165
  }
166
  $main::lxdebug->dump(0, 'WH: KAT2:',\@cat);
167

  
168
  my $categories->{shop_category} = \@cat;
160 169

  
161 170
  my $params = delete($::form->{shop_part}) || { };
162 171

  
SL/ShopConnector/Shopware.pm
146 146

  
147 147
  my $data = $self->connector->get("http://$url/api/categories");
148 148
  my $data_json = $data->content;
149
  $main::lxdebug->dump(0, 'WH: IMPORT', \$data_json);
150 149
  my $import = SL::JSON::decode_json($data_json);
151 150
  my @daten = @{$import->{data}};
152 151
  my %categories = map { ($_->{id} => $_) } @daten;
......
160 159
  return \@daten;
161 160
}
162 161

  
163
sub get_article {
164
}
165

  
166 162
sub get_articles {
167 163
  my ($self, $json_data) = @_;
168
  $main::lxdebug->dump(0, 'WH: JSON: ', \$json_data);
169 164

  
170 165
}
171 166

  
......
238 233
                      active        => $shop_part->active,
239 234
                      images        => [ @images3 ],
240 235
                      __options_images => { replace => 1, },
241
                      #categories    => [ { name => 'Deutsch\test2' }, ], #[ $categories ],
236
                      categories    => [ { path => 'Deutsch|test2' }, ], #[ $categories ],
242 237

  
243 238
                    )
244 239
                  ;
......
253 248
  #my $delImg = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $del_imgString);
254 249
    #update
255 250
    my $upload = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $dataString);
251
    my $data_json = $upload->content;
252
    my $upload_content = SL::JSON::decode_json($data_json);
256 253
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);
254
    return $upload_content->{success};
257 255
  }else{
258 256
    #upload
259 257
$main::lxdebug->message(0, "WH: else success: ". $import->{success});
260 258
    my $upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
259
    my $data_json = $upload->content;
260
    my $upload_content = SL::JSON::decode_json($data_json);
261 261
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);
262
    return $upload_content->{success};
262 263
  }
263 264

  
264 265
}
templates/webpages/shop_part/categories.html
8 8
[%  LxERP.t8("Part") %]: [% HTML.escape(SELF.shop_part.part.displayable_name) %]<br>
9 9
[%  LxERP.t8("Shop") %]: [% HTML.escape(SELF.shop_part.shop.description) %]
10 10
<br>
11
[%   Dumper.dump_html(SELF.shop_part.shop_category) %]
11
[% # Dumper.dump_html(SELF.shop_part.shop_category) %]
12
<br>
13
[% # Dumper.dump_html(CATEGORIES) %]
12 14

  
13 15
<form action="controller.pl" method="post">
14 16
  [% BLOCK recurse %]
17
  [% # path = '' %]<!-- TODO: Pfad wg neuer Kategorie im Shop anlegen -->
15 18
    [% FOREACH obj = data %]
16 19
      <ul>
17 20
        <li>
18 21
        [% checked = '' %]
19
        [% IF SELF.shop_part.shop_category.grep(obj.name).size %]
22
        [% # path = path _ obj.name %]
23
        [% # test = path.split('\|') %]
24
        [% # Dumper.dump_html(SELF.shop_part.shop_category.size) %]
25
        [% IF SELF.shop_part.shop_category.1.grep(obj.name).size %]
20 26
          [% checked = 'checked' %]
27
        [% ELSE %]
28
          [% FOREACH cat_row = SELF.shop_part.shop_category %]
29
            [% IF cat_row.1.grep(obj.name).size %]
30
              [% checked = 'checked' %]
31
            [% END %]
32
          [% END %]
21 33
        [% END %]
22
          [% L.checkbox_tag('categories[]',value=obj.name, checked=checked) %][% HTML.escape(obj.name) %]</li>
34
          [% L.checkbox_tag('categories[]',value=obj.id _"," _ obj.name _ ",PFAD", checked=checked) %][% HTML.escape(obj.name) %]</li>
23 35
        [% IF obj.childrenCount >= 1 %]
36
          [% # path = path _ '|' %]
24 37
          [% INCLUDE recurse data=obj.children %]
25 38
        [% END %]
26 39
      </ul>
......
31 44
<!-- TODO: Is still hardcoded 'Root' is shopware specified -->
32 45
        [% IF row.name == 'Root' %]
33 46
          [% IF row.childrenCount >= 1 %]
34
            [% INCLUDE recurse data=row.children %]
47
            [% path = '' %]
48
            [% INCLUDE recurse data=row.children path=path %]
35 49
          [% END %]
36 50
        [% END %]
37 51
      [% END %]

Auch abrufbar als: Unified diff