Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d1582152

Von Werner Hahn vor mehr als 8 Jahren hinzugefügt

  • ID d15821524b7de331662d92b91d76675cb1c15043
  • Vorgänger a42d9378
  • Nachfolger 0067f9b2

Shoppart: Last Upload article is written in db

Unterschiede anzeigen:

SL/Controller/ShopPart.pm
49 49

  
50 50
  # the connector deals with parsing/result verification, just needs to return success or failure
51 51
  if ( $return == 1 ) {
52
    # TODO: write update time to DB
53 52
    my $now = DateTime->now;
54 53
    my $attributes->{last_update} = $now;
55 54
    $self->shop_part->assign_attributes(%{ $attributes });
......
69 68
  my $images = SL::DB::Manager::File->get_all_sorted( where => [ trans_id => $::form->{id}, modul => $::form->{modul}, file_content_type => { like => 'image/%' } ], sort_by => 'position' );
70 69

  
71 70
  $self->render('shop_part/_list_images', { header => 0 }, IMAGES => $images);
72

  
73 71
}
74 72

  
75 73
sub action_ajax_upload_file{
SL/ShopConnector/Shopware.pm
12 12
use Data::Dumper;
13 13
use Sort::Naturally ();
14 14
use Encode qw(encode_utf8);
15
use SL::Controller::ShopPart;
15 16

  
16 17
use Rose::Object::MakeMethods::Generic (
17 18
  'scalar --get_set_init' => [ qw(connector url) ],
......
197 198
  my $data = $self->connector->get("http://$url/api/articles/$part->{partnumber}?useNumberAsId=true");
198 199
  my $data_json = $data->content;
199 200
  my $import = SL::JSON::decode_json($data_json);
200
  # mapping to shopware
201

  
202
  # get the right price
203
  my ( $price_src_str, $price_src_id ) = split(/\//,$shop_part->active_price_source);
204
  require SL::DB::Part;
205
  my $price;
206
  if ($price_src_str eq "master_data") {
207
    my $part = SL::DB::Manager::Part->get_all( where => [id => $shop_part->part_id], with_objects => ['prices'],limit => 1)->[0];
208
    $price = $part->$price_src_id;
209
  }else{
210
    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];
211
    $price =  $part->prices->[0]->price;
212
  }
213
  # mapping to shopware still missing attributes,metatags
201 214
  my %shop_data =  (  name              => $part->{description},
202 215
                      taxId             => 4, # TODO Hardcoded kann auch der taxwert sein zB. tax => 19.00
203 216
                      mainDetail        => { number   => $part->{partnumber},
204 217
                                         inStock  => $part->{onhand},
205 218
                                         prices   =>  [ {          from   => 1,
206
                                                                   price  => $part->{sellprice},
219
                                                                   price  => $price,
207 220
                                                        customerGroupKey  => 'EK',
208 221
                                                      },
209 222
                                                    ],

Auch abrufbar als: Unified diff