Skip to content

Commit

Permalink
[!!!][BUGFIX] updates reinitialization of the shop context in the Api…
Browse files Browse the repository at this point in the history
…UrlDecorator to use the correct base URL in language sub-shops

[!!!] this is a breaking change, as the URL generation for the entity "pxShopwareUrl" in all API responses may change regarding your setup
  • Loading branch information
EvilBMP committed Feb 19, 2020
1 parent 993d384 commit 3b17e80
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 5 additions & 8 deletions Components/ApiUrlDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public function __construct(\Enlight_Controller_Action $controller, Container $c
$this->request = $this->controller->Request();
$this->view = $this->controller->View();
$this->shopResource = Manager::getResource('shop');
$this->isPxShopwareRequest = ($this->request->getParam('px_shopware') != null) ? (bool)$this->request->getParam('px_shopware') : false;
$this->isPxShopwareRequest = ($this->request->getParam('px_shopware') !== null) ? (bool)$this->request->getParam('px_shopware') : false;

if ($this->isPxShopwareRequest) {
$language = ($this->request->getParam('language') != null) ? (int)$this->request->getParam('language') : false;
$language = ($this->request->getParam('language') !== null) ? (int)$this->request->getParam('language') : false;
if ($language !== false) {
// we cannot use this query, because of bug described here: https://issues.shopware.com/#/issues/SW-15388
// $this->shop = $this->shopResource->getRepository()->queryBy(array('active' => TRUE, 'locale' => $language))->getOneOrNullResult();
Expand All @@ -99,18 +99,16 @@ public function __construct(\Enlight_Controller_Action $controller, Container $c
} else {
// if '___VERSION___' is given, it seems to be a composer installation
// composer is available from 5.4 on and there we have the container 'shopware.release'
/** @var \Shopware\Components\ShopwareReleaseStruct $shopwareRelease */
$shopwareRelease = $this->container->get('shopware.release');
$currentVersion = $shopwareRelease->getVersion();
$currentVersion = $this->container->getParameter('shopware.release.version');
}

$context = $router->getContext();
$newContext = Context::createFromShop($this->shop, $this->config);
// Reuse the host
if ($newContext->getHost() === null) {
$newContext->setHost($context->getHost());
$newContext->setBaseUrl($context->getBaseUrl());
$newContext->setSecure($context->isSecure());
$newContext->setBaseUrl($this->shop->getBaseUrl() ?: $context->getBaseUrl());
$newContext->setSecure($this->shop->getSecure() ?: $context->isSecure());
}
if (version_compare($currentVersion, '5.4.0', '<')) {
// the following methods are removed in Shopware 5.4
Expand Down Expand Up @@ -162,7 +160,6 @@ public function addUrl()
}
$data = $items;
}

}

$this->controller->View()->clearAssign('data');
Expand Down
13 changes: 12 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<label lang="de">TYPO3-Connector</label>
<label lang="en">TYPO3-Connector</label>

<version>2.4.1</version>
<version>2.5.0</version>

<copyright>© 2019 by portrino GmbH</copyright>

Expand All @@ -16,6 +16,17 @@
<description lang="de">Ermöglicht die Kommunikation mit der TYPO3-Erweiterung "PxShopware"</description>
<description lang="en">Enables communication with TYPO3-Extension "PxShopware".</description>

<changelog version="2.5.0">
<changes lang="de">
[!!!][BUGFIX] Aktualisiert die Neuinitialisierung des Shop-Kontexts im ApiUrlDecorator, um die richtige Basis-URL in Sprach-Sub-Shops zu verwenden
[!!!] Dies ist eine wichtige Änderung, da sich die URL-Generierung für die Entität "pxShopwareUrl" in allen API-Antworten in Bezug auf Ihr Setup ändern kann
</changes>
<changes lang="en">
[!!!][BUGFIX] updates reinitialization of the shop context in the ApiUrlDecorator to use the correct base URL in language sub-shops
[!!!] this is a breaking change, as the URL generation for the entity "pxShopwareUrl" in all API responses may change regarding your setup
</changes>
</changelog>

<changelog version="2.4.1">
<changes lang="de">
[BUGFIX] Versionsprüfung nicht kompatibel mit Shopware 5.6 -> thx @jonakieling - refs #4
Expand Down

0 comments on commit 3b17e80

Please sign in to comment.