Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4edf2b76

Von Werner Hahn vor fast 8 Jahren hinzugefügt

  • ID 4edf2b76cce4e40642b5717ad3b0439bed02b1f1
  • Vorgänger c033e49e
  • Nachfolger a206d0be

ShopPart: Bilder hochladen geht jetzt.

Unterschiede anzeigen:

SL/ShopConnector/Shopware.pm
187 187
  my $cvars = { map { ($_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid }) } @{ $part->cvars_by_config } };
188 188
  my $categories = { map { ( name => $_) } @{ $shop_part->{shop_category} } };
189 189
  $main::lxdebug->dump(0, 'WH: CATEGORIES',\$categories);
190
  my $images = SL::DB::Manager::File->get_all( modul => 'shop_part', trans_id => $part->{id});
191
  $main::lxdebug->dump(0, 'WH: IMAGES',\$images);
192
  $images = { map { ( url => 'data:' . $_->{file_content_type} . ';base64,' . MIME::Base64::encode($_->{file_content}),
190
  my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]);
191
  $main::lxdebug->dump(0, 'WH: IMAGES',\@{ $images } );
192
  my $images2 = { map {
193
                    ( link        => 'data:' . $_->{file_content_type} . ';base64,' . MIME::Base64::encode($_->{file_content},''),
193 194
                      description => $_->{title},
194 195
                      position    => $_->{position},
195
                      extension   => 'jpg',
196
                      path        => $_->{filename},
196
                      extension   => 'jpg', # muss $extionsion sein
197
                      path        => $_->{filename}, # muss $path sein
197 198
                    ) } @{ $images } };
198
  $main::lxdebug->dump(0, 'WH: IMAGES 2 ',\$images);
199
$main::lxdebug->dump(0, 'WH: Partnumber', $part->{partnumber});
199
  $main::lxdebug->dump(0, 'WH: IMAGES 2 ',\$images2);
200

  
201
  my @images3 = ();
202
  foreach my $img (@{ $images }) {
203
    $main::lxdebug->dump(0, 'WH: FOR: ', \$img);
204

  
205
    my ($path, $extension) = (split /\./, $img->{filename});
206
    $main::lxdebug->message(0, "WH: PATH: $path Ext: $extension");
207

  
208
    my $temp ={
209
                      ( link        => 'data:' . $img->{file_content_type} . ';base64,' . MIME::Base64::encode($img->{file_content},''),
210
                        description => $img->{title},
211
                        position    => $img->{position},
212
                        extension   => $extension,
213
                        path        => $path,
214
                      )}    ;
215
    push( @images3, $temp);
216
  }
217
  $main::lxdebug->dump(0, 'WH: IMAGES 3 ',\@images3);
200 218

  
201 219
  my $data = $self->connector->get("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true");
202 220
  my $data_json = $data->content;
......
218 236
                      supplier      => $cvars->{freifeld_7}->{value},
219 237
                      description   => $shop_part->{shop_description},
220 238
                      active        => $shop_part->active,
221
                      images        => [ $images ],
239
                      images        => [ @images3 ],
240
                      __options_images => { replace => 1, },
222 241
                      #categories    => [ { name => 'Deutsch\test2' }, ], #[ $categories ],
242

  
223 243
                    )
224 244
                  ;
225 245
$main::lxdebug->dump(0, 'WH: SHOPDATA', \%shop_data );
......
228 248
$main::lxdebug->message(0, 'WH: JSONDATA2 '.$dataString);
229 249
  if($import->{success}){
230 250
$main::lxdebug->message(0, "WH: if success: ". $import->{success});
251
  my %del_img =  ( images        => [ {} ], ) ;
252
  my $del_imgString = SL::JSON::to_json(\%del_img);
253
  #my $delImg = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $del_imgString);
231 254
    #update
232 255
    my $upload = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $dataString);
233 256
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);

Auch abrufbar als: Unified diff