Skip to content
Code-Schnipsel Gruppen Projekte
Commit b73591fb erstellt von Michael Danielczok's avatar Michael Danielczok
Dateien durchsuchen

fix: Consider project language in product url.

Übergeordneter ce3532a8
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
if (\strlen(URL_DIR) == 1) { if (\strlen(URL_DIR) == 1) {
$_REQUEST['_url'] = \ltrim($_REQUEST['_url'], URL_DIR); $_REQUEST['_url'] = \ltrim($_REQUEST['_url'], URL_DIR);
} else { } else {
$from = '/'.\preg_quote(URL_DIR, '/').'/'; $from = '/' . \preg_quote(URL_DIR, '/') . '/';
$_REQUEST['_url'] = \preg_replace($from, '', $_REQUEST['_url'], 1); $_REQUEST['_url'] = \preg_replace($from, '', $_REQUEST['_url'], 1);
} }
...@@ -93,7 +93,13 @@ ...@@ -93,7 +93,13 @@
$categoryId = $Site->getAttribute('quiqqer.products.settings.categoryId'); $categoryId = $Site->getAttribute('quiqqer.products.settings.categoryId');
$Product = Products\Handler\Products::getProductByUrl($refNo, $categoryId); $Product = Products\Handler\Products::getProductByUrl($refNo, $categoryId);
} catch (QUI\Exception $Exception) { } catch (QUI\Exception $Exception) {
Log::addDebug('Products::getProductByUrl :: '.$Exception->getMessage()); try {
if (\is_numeric($refNo)) {
$Product = Products\Handler\Products::getProduct($refNo);
}
} catch (QUI\Exception $Exception) {
Log::addDebug('Products::getProductByUrl :: ' . $Exception->getMessage());
}
} }
try { try {
...@@ -112,10 +118,14 @@ ...@@ -112,10 +118,14 @@
$Site->setAttribute('canonical', $Product->getParent()->getUrl($Project)); $Site->setAttribute('canonical', $Product->getParent()->getUrl($Project));
} }
// if product url is with lang flag /en/
if (\strpos($productUrl, '/', 1) === 3) {
$productUrl = \mb_substr($productUrl, 3);
}
// forwarding, if the product has a new URL // forwarding, if the product has a new URL
// can happen if the product was previously in "all products". // can happen if the product was previously in "all products".
if ($productUrl != URL_DIR.$_REQUEST['_url']) { if ($productUrl != URL_DIR . $_REQUEST['_url']) {
$urlencoded = \urlencode($productUrl); $urlencoded = \urlencode($productUrl);
$urlencoded = \str_replace('%2F', '/', $urlencoded); $urlencoded = \str_replace('%2F', '/', $urlencoded);
...@@ -160,7 +170,7 @@ ...@@ -160,7 +170,7 @@
); );
$Site->setAttribute( $Site->setAttribute(
$language.'-link', $language . '-link',
$Product->getUrlRewrittenWithHost($LanguageProject) $Product->getUrlRewrittenWithHost($LanguageProject)
); );
} catch (QUI\Exception $Exception) { } catch (QUI\Exception $Exception) {
...@@ -220,16 +230,16 @@ ...@@ -220,16 +230,16 @@
foreach ($fields as $fieldId) { foreach ($fields as $fieldId) {
if (\strpos($fieldId, 'S') === 0) { if (\strpos($fieldId, 'S') === 0) {
$title = QUI::getLocale()->get('quiqqer/products', 'sortable.'.\mb_substr($fieldId, 1)); $title = QUI::getLocale()->get('quiqqer/products', 'sortable.' . \mb_substr($fieldId, 1));
$ProductList->addSort( $ProductList->addSort(
$title.' '.QUI::getLocale()->get('quiqqer/products', 'sortASC'), $title . ' ' . QUI::getLocale()->get('quiqqer/products', 'sortASC'),
$fieldId.' ASC' $fieldId . ' ASC'
); );
$ProductList->addSort( $ProductList->addSort(
$title.' '.QUI::getLocale()->get('quiqqer/products', 'sortDESC'), $title . ' ' . QUI::getLocale()->get('quiqqer/products', 'sortDESC'),
$fieldId.' DESC' $fieldId . ' DESC'
); );
continue; continue;
...@@ -243,13 +253,13 @@ ...@@ -243,13 +253,13 @@
$title = $Field->getTitle(); $title = $Field->getTitle();
$ProductList->addSort( $ProductList->addSort(
$title.' '.QUI::getLocale()->get('quiqqer/products', 'sortASC'), $title . ' ' . QUI::getLocale()->get('quiqqer/products', 'sortASC'),
'F'.$fieldId.' ASC' 'F' . $fieldId . ' ASC'
); );
$ProductList->addSort( $ProductList->addSort(
$title.' '.QUI::getLocale()->get('quiqqer/products', 'sortDESC'), $title . ' ' . QUI::getLocale()->get('quiqqer/products', 'sortDESC'),
'F'.$fieldId.' DESC' 'F' . $fieldId . ' DESC'
); );
} catch (QUI\Exception $Exception) { } catch (QUI\Exception $Exception) {
} }
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren