From 53e8b269113c3d06991224d2096c9a4a24d76f72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 3 Feb 2022 10:39:54 +0100 Subject: [PATCH] Shopware6: Optionalen Proxy erlauben und Protokoll http oder https initialisieren --- SL/DB/MetaSetup/Shop.pm | 1 + SL/DB/Shop.pm | 1 + SL/ShopConnector/Shopware6.pm | 3 +++ sql/Pg-upgrade2/shops_6.sql | 6 ++++++ templates/webpages/shops/form.html | 4 ++++ 5 files changed, 15 insertions(+) create mode 100644 sql/Pg-upgrade2/shops_6.sql diff --git a/SL/DB/MetaSetup/Shop.pm b/SL/DB/MetaSetup/Shop.pm index 690afc585..adb6b3a49 100644 --- a/SL/DB/MetaSetup/Shop.pm +++ b/SL/DB/MetaSetup/Shop.pm @@ -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' }, diff --git a/SL/DB/Shop.pm b/SL/DB/Shop.pm index 750e3a3b7..6b0035067 100644 --- a/SL/DB/Shop.pm +++ b/SL/DB/Shop.pm @@ -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; diff --git a/SL/ShopConnector/Shopware6.pm b/SL/ShopConnector/Shopware6.pm index 9944b33d9..38ec37f97 100644 --- a/SL/ShopConnector/Shopware6.pm +++ b/SL/ShopConnector/Shopware6.pm @@ -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 index 000000000..788bdb94c --- /dev/null +++ b/sql/Pg-upgrade2/shops_6.sql @@ -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 ''; diff --git a/templates/webpages/shops/form.html b/templates/webpages/shops/form.html index 3ab333ba2..2f08e7282 100644 --- a/templates/webpages/shops/form.html +++ b/templates/webpages/shops/form.html @@ -43,6 +43,10 @@ [% 'Port' | $T8 %] [%- L.input_tag("shop.port", SELF.shop.port, size=5) %] + + [% 'Proxy' | $T8 %] + [%- L.input_tag("shop.proxy", SELF.shop.proxy, size=size) %] + [% 'Path' | $T8 %] [%- L.input_tag("shop.path", SELF.shop.path, size=size) %] -- 2.20.1