Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2b511d4d

Von Werner Hahn vor mehr als 6 Jahren hinzugefügt

  • ID 2b511d4d9ae2516dd57f74250b5f0d735c129ac1
  • Vorgänger 451d54ce
  • Nachfolger b501cb33

Shopmodul: Shoppart - Alle Daten werden angezeigt (Lager Lokal/Shop, Preisquelle, Preis) Lastupload Zeit wird in DB geschrieben und auch angezeigt

Shoppart: Alle Daten werden angezeigt (Lager Lokal/Shop, Preisquelle, Preis) Lastupload Zeit wird in DB geschrieben und auch angezeigt.
Formatierungen in den js für Zahlen fehlen noch Kleinere TODOs

Conflicts:
SL/Controller/ShopPart.pm
SL/ShopConnector/Shopware.pm
templates/webpages/ic/tabs/_shop.html

Shoppart: Last Upload article is written in db

Conflicts:
SL/ShopConnector/Shopware.pm

Conflicts:
SL/Controller/ShopPart.pm
SL/ShopConnector/Shopware.pm
js/kivi.shop_part.js

Unterschiede anzeigen:

SL/ShopConnector/Shopware.pm
12 12
use SL::DB::ShopOrder;
13 13
use SL::DB::ShopOrderItem;
14 14
use Data::Dumper;
15
use Sort::Naturally ();
16
use Encode qw(encode_utf8);
17
use SL::Controller::ShopPart;
15 18

  
16 19
use Rose::Object::MakeMethods::Generic (
17 20
  'scalar --get_set_init' => [ qw(connector url) ],
......
185 188
  $main::lxdebug->dump(0, 'WH: UPDATE JSON: ', \$json);
186 189
  my $url = $self->url;
187 190
  my $part = SL::DB::Part->new(id => $shop_part->{part_id})->load;
188
  #my $part = $shop_part->part;
189
  $main::lxdebug->dump(0, 'WH: Part',\$part);
191
$main::lxdebug->dump(0, 'WH: SHOPPART: ',\$part);
190 192

  
191
  # TODO: Prices (pricerules, pricegroups,
193
  # TODO: Prices (pricerules, pricegroups, multiple prices)
192 194
  my $cvars = { map { ($_->config->name => { value => $_->value_as_text, is_valid => $_->is_valid }) } @{ $part->cvars_by_config } };
193 195
  #my $categories = { map { ( name => $_) } @{ $shop_part->{shop_category} } };
194 196
  my @cat = ();
......
199 201
    $main::lxdebug->dump(0, 'WH: TEMP: ', \$temp);
200 202

  
201 203
    push ( @cat, $temp );
202
    #push ( @cat, map { ( name => $_[1]) } @{ $row_cat } );
203 204
  }
204
  $main::lxdebug->dump(0, 'WH: CATEGORIES',\@cat);
205

  
205 206
  my $images = SL::DB::Manager::File->get_all( where => [ modul => 'shop_part', trans_id => $part->{id} ]);
206
  $main::lxdebug->dump(0, 'WH: IMAGES',\@{ $images } );
207
  my $images2 = { map {
208
                    ( link        => 'data:' . $_->{file_content_type} . ';base64,' . MIME::Base64::encode($_->{file_content},''),
209
                      description => $_->{title},
210
                      position    => $_->{position},
211
                      extension   => 'jpg', # muss $extionsion sein
212
                      path        => $_->{filename}, # muss $path sein
213
                    ) } @{ $images } };
214
  $main::lxdebug->dump(0, 'WH: IMAGES 2 ',\$images2);
215

  
216
  my @images3 = ();
207
  my @upload_img = ();
217 208
  foreach my $img (@{ $images }) {
218 209
    $main::lxdebug->dump(0, 'WH: FOR: ', \$img);
219 210

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

  
223
    my $temp ={
224
                      ( link        => 'data:' . $img->{file_content_type} . ';base64,' . MIME::Base64::encode($img->{file_content},''),
225
                        description => $img->{title},
226
                        position    => $img->{position},
227
                        extension   => $extension,
228
                        path        => $path,
212
    my $temp ={ ( link        => 'data:' . $img->{file_content_type} . ';base64,' . MIME::Base64::encode($img->{file_content},''),
213
                  description => $img->{title},
214
                  position    => $img->{position},
215
                  extension   => $extension,
229 216
                      )}    ;
230 217
    push( @images3, $temp);
231 218
  }
......
234 221
  my $data = $self->connector->get("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true");
235 222
  my $data_json = $data->content;
236 223
  my $import = SL::JSON::decode_json($data_json);
237
  $main::lxdebug->dump(0, 'WH: IMPORT', \$import);
238
  $main::lxdebug->dump(0, 'WH: Active', $shop_part->active);
239

  
240 224

  
241
  my %shop_data =  (  name          => $part->{description},
242
                      taxId         => 4, # TODO Hardcoded kann auch der taxwert sein zB. tax => 19.00
243
                      mainDetail    => { number   => $part->{partnumber},
225
  # get the right price
226
  my ( $price_src_str, $price_src_id ) = split(/\//,$shop_part->active_price_source);
227
  require SL::DB::Part;
228
  my $price;
229
  if ($price_src_str eq "master_data") {
230
    my $part = SL::DB::Manager::Part->get_all( where => [id => $shop_part->part_id], with_objects => ['prices'],limit => 1)->[0];
231
    $price = $part->$price_src_id;
232
  }else{
233
    my $part = SL::DB::Manager::Part->get_all( where => [id => $shop_part->part_id, 'prices.'.pricegroup_id => $price_src_id], with_objects => ['prices'],limit => 1)->[0];
234
    $price =  $part->prices->[0]->price;
235
  }
236
  # mapping to shopware still missing attributes,metatags
237
  my %shop_data =  (  name              => $part->{description},
238
                      taxId             => 4, # TODO Hardcoded kann auch der taxwert sein zB. tax => 19.00
239
                      mainDetail        => { number   => $part->{partnumber},
244 240
                                         inStock  => $part->{onhand},
245 241
                                         prices   =>  [ {          from   => 1,
246
                                                                   price  => $part->{sellprice},
242
                                                                   price  => $price,
247 243
                                                        customerGroupKey  => 'EK',
248 244
                                                      },
249 245
                                                    ],
......
257 253

  
258 254
                    )
259 255
                  ;
260
$main::lxdebug->dump(0, 'WH: SHOPDATA', \%shop_data );
261
my $dataString = SL::JSON::to_json(\%shop_data);
262
$dataString = encode_utf8($dataString);
263
$main::lxdebug->message(0, 'WH: JSONDATA2 '.$dataString);
256
  my $dataString = SL::JSON::to_json(\%shop_data);
257
  $dataString = encode_utf8($dataString);
258

  
259
  my $upload_content;
264 260
  if($import->{success}){
265 261
$main::lxdebug->message(0, "WH: if success: ". $import->{success});
266 262
  my %del_img =  ( images        => [ {} ], ) ;
......
269 265
    #update
270 266
    my $upload = $self->connector->put("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true",Content => $dataString);
271 267
    my $data_json = $upload->content;
272
    my $upload_content = SL::JSON::decode_json($data_json);
273
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);
274
    return $upload_content->{success};
268
    $upload_content = SL::JSON::decode_json($data_json);
275 269
  }else{
276 270
    #upload
277 271
$main::lxdebug->message(0, "WH: else success: ". $import->{success});
278 272
    my $upload = $self->connector->post("http://$url/api/articles/",Content => $dataString);
279 273
    my $data_json = $upload->content;
280
    my $upload_content = SL::JSON::decode_json($data_json);
281
$main::lxdebug->dump(0, "WH:2 else success: ", \$upload);
282
    return $upload_content->{success};
274
    $upload_content = SL::JSON::decode_json($data_json);
275
  }
276
  if(@upload_img) {
277
    $self->connector->put("http://$url/api/generateArticleImages/$part->{partnumber}?useNumberAsId=true");
278
    #$self->connector->delete("http://$url/api/caches/");
283 279
  }
280
  return $upload_content->{success};
281
}
282

  
283
sub get_article {
284
  my ($self,$partnumber) = @_;
284 285

  
285
>>>>>>> b616804... Kategorien werden mit ID und Name in die DB geschrieben. Ein Komma im Name erzeugt noch Fehler. Der Pfad muss noch gemacht werden
286
  my $url = $self->url;
287
  my $data = $self->connector->get("http://$url/api/articles/$partnumber?useNumberAsId=true");
288
  my $data_json = $data->content;
289
  return SL::JSON::decode_json($data_json);
286 290
}
287 291

  
288 292
sub init_url {

Auch abrufbar als: Unified diff