Shopware6: Optionalen Proxy erlauben und Protokoll http oder https initialisieren
authorJan Büren <jan@kivitendo.de>
Thu, 3 Feb 2022 09:39:54 +0000 (10:39 +0100)
committerJan Büren <jan@kivitendo.de>
Fri, 11 Feb 2022 14:19:57 +0000 (15:19 +0100)
SL/DB/MetaSetup/Shop.pm
SL/DB/Shop.pm
SL/ShopConnector/Shopware6.pm
sql/Pg-upgrade2/shops_6.sql [new file with mode: 0644]
templates/webpages/shops/form.html

index 690afc5..adb6b3a 100644 (file)
@@ -24,6 +24,7 @@ __PACKAGE__->meta->columns(
   price_source             => { type => 'text' },
   pricetype                => { type => 'text' },
   protocol                 => { type => 'text', default => 'http', not_null => 1 },
+  proxy                    => { type => 'text', default => '' },
   realm                    => { type => 'text' },
   server                   => { type => 'text' },
   shipping_costs_parts_id  => { type => 'integer' },
index 750e3a3..6b00350 100644 (file)
@@ -21,6 +21,7 @@ sub validate {
   push @errors, $::locale->text('The path is missing.')        unless $self->{path};
   push @errors, $::locale->text('The Host Name is missing')    unless $self->{server};
   push @errors, $::locale->text('The Host Name seems invalid') unless $self->{server} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
+  push @errors, $::locale->text('The Proxy Name seems invalid') unless $self->{proxy} =~ m/[0-9A-Za-z].\.[0-9A-Za-z]/;
   push @errors, $::locale->text('Orders to fetch neeeds a positive Integer')
                                                                unless $self->{orders_to_fetch} > 0;
 
index 9944b33..38ec37f 100644 (file)
@@ -710,6 +710,9 @@ sub init_connector {
   my ($self) = @_;
 
   my $client = REST::Client->new(host => $self->config->server);
+
+  $client->getUseragent()->proxy([$self->config->protocol], $self->config->proxy) if $self->config->proxy;
+
   $client->addHeader('Content-Type', 'application/json');
   $client->addHeader('charset',      'UTF-8');
   $client->addHeader('Accept',       'application/json');
diff --git a/sql/Pg-upgrade2/shops_6.sql b/sql/Pg-upgrade2/shops_6.sql
new file mode 100644 (file)
index 0000000..788bdb9
--- /dev/null
@@ -0,0 +1,6 @@
+-- @tag: shop_add_proxy
+-- @description: Shop-Config um Option Proxy erweitert
+-- @depends: shops_5
+-- @ignore: 0
+
+ALTER TABLE shops ADD COLUMN proxy TEXT default '';
index 3ab333b..2f08e72 100644 (file)
     <th align="right">[% 'Port' | $T8 %]</th>
     <td>[%- L.input_tag("shop.port", SELF.shop.port, size=5) %]</td>
   </tr>
+  <tr>
+    <th align="right">[% 'Proxy' | $T8 %]</th>
+    <td>[%- L.input_tag("shop.proxy", SELF.shop.proxy, size=size) %]</td>
+  </tr>
   <tr>
     <th align="right">[% 'Path' | $T8 %]</th>
     <td>[%- L.input_tag("shop.path", SELF.shop.path, size=size) %]</td>