X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/86d70efe93c53445626d8fd1e052f96c7c762cf6..fa04f8138cc6447:/SL/ShopConnector/Shopware.pm diff --git a/SL/ShopConnector/Shopware.pm b/SL/ShopConnector/Shopware.pm index 9cd766e90..938f99b17 100644 --- a/SL/ShopConnector/Shopware.pm +++ b/SL/ShopConnector/Shopware.pm @@ -46,6 +46,7 @@ sub get_one_order { }; if(!@errors){ + $self->set_orderstatus($import->{data}->{id}, "fetched"); $of++; }else{ flash_later('error', $::locale->text('Database errors: #1', @errors)); @@ -71,7 +72,7 @@ sub get_new_orders { my $last_order_number = $self->config->last_order_number; my $otf = $self->config->orders_to_fetch; my $of = 0; - my $last_data = $self->connector->get($url . "api orders/$last_order_number?useNumberAsId=true"); + my $last_data = $self->connector->get($url . "api/orders/$last_order_number?useNumberAsId=true"); my $last_data_json = $last_data->content; my $last_import = SL::JSON::decode_json($last_data_json); @@ -100,6 +101,7 @@ sub get_new_orders { }; if(!@errors){ + $self->set_orderstatus($shoporder->{id}, "fetched"); $of++; }else{ flash_later('error', $::locale->text('Database errors: #1', @errors)); @@ -401,6 +403,15 @@ sub get_article { return SL::JSON::decode_json($data_json); } +sub set_orderstatus { + my ($self,$order_id, $status) = @_; + if ($status eq "fetched") { $status = 1; } + if ($status eq "completed") { $status = 2; } + my %new_status = (orderStatusId => $status); + my $new_status_json = SL::JSON::to_json(\%new_status); + $self->connector->put($self->url . "api/orders/$order_id", Content => $new_status_json); +} + sub init_url { my ($self) = @_; $self->url($self->config->protocol . "://" . $self->config->server . ":" . $self->config->port . $self->config->path);