Skip to content

Commit

Permalink
Merge pull request #1191 from plentymarkets/fix/hreflang
Browse files Browse the repository at this point in the history
exclude shop booster params from canonical check
  • Loading branch information
stentrop authored Feb 1, 2024
2 parents 265d838 + 4d9be32 commit 0615212
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions meta/documents/changelog_de.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes für IO

## v5.0.62 (2024-XX-XX) <a href="https://github.com/plentymarkets/plugin-io/compare/5.0.61...5.0.62" target="_blank" rel="noopener"><b>Übersicht aller Änderungen</b></a>

### Behoben

- Ein Fehler bei der Prüfung von kanonischen Urls in Kombination mit ausgeschlossenen ShopBooster Parametern, kann zu fehlenden alternate links führen. Dies wurde behoben.

## v5.0.61 (2023-10-30) <a href="https://github.com/plentymarkets/plugin-io/compare/5.0.60...5.0.61" target="_blank" rel="noopener"><b>Übersicht aller Änderungen</b></a>

### Behoben
Expand Down
6 changes: 6 additions & 0 deletions meta/documents/changelog_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for IO

## v5.0.62 (2023-XX-XX) <a href="https://github.com/plentymarkets/plugin-io/compare/5.0.61...5.0.62" target="_blank" rel="noopener"><b>Overview of all changes</b></a>

### Fixed

- An error when checking canonical urls in combination with excluded ShopBooster parameters can lead to missing alternate links. This was fixed.

## v5.0.61 (2023-10-30) <a href="https://github.com/plentymarkets/plugin-io/compare/5.0.60...5.0.61" target="_blank" rel="noopener"><b>Overview of all changes</b></a>

### Fixed
Expand Down
13 changes: 12 additions & 1 deletion src/Services/UrlService.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,19 @@ public function isCanonical($lang = null)
$request = pluginApp(Request::class);
$requestUri = $request->getRequestUri();

$url = explode('?', $requestUri)[0];

$queryParameters = $request->query();
$queryParameters = Utils::cleanUpExcludesContentCacheParams($queryParameters);
$queryParameters = http_build_query($queryParameters, null, '&', PHP_QUERY_RFC3986);
if (strlen($queryParameters) > 0)
{
$url .= '?' . $queryParameters;
}


/** @var UrlQuery $urlQuery */
$urlQuery = pluginApp(UrlQuery::class, ['path' => $requestUri]);
$urlQuery = pluginApp(UrlQuery::class, ['path' => $url]);
$requestUrl = $urlQuery->toAbsoluteUrl($lang !== $defaultLanguage);
$canonical = $this->getCanonicalURL($lang);

Expand Down

0 comments on commit 0615212

Please sign in to comment.