Closed vasiok32k closed 2 years ago
The issue is caused by line 186 of Model/Catalog/Layer/Url/Strategy/QueryParameterStrategy.php
which reads as follows:
$url = str_replace($this->url->getBaseUrl(), '', $url);
Removing this line or prepending a /
to the result seems to resolve the issue.
The issue is introduced in v3.3.3 in commit 853468b with the following commit message:
Add storeId if available in get category; remove double store code from url if available in query param stratey and path slug strategy
BTW This issue only occurs when using the default Emico\Tweakwise\Model\Catalog\Layer\Url\Strategy\QueryParameterStrategy
URL strategy. As a workaround you can also switch to the Emico\Tweakwise\Model\Catalog\Layer\Url\Strategy\PathSlugStrategy
strategy.
@vasiok32k Please create the PR and we will review and merge when accepted
@Hnto ,
As said in a different issue, I would like to propose a solution to this. For our client we have implemented a patch which solved the issue with the Duplicated URL's. I love to know what you think about this fix and if it is possible to implement this into a new version.
That patch was added to fix issue in the Emico_Tweakwise module described there:
https://github.com/EmicoEcommerce/Magento2Tweakwise/issues/166
--- a/view/frontend/templates/product/layered/tree/item.phtml
+++ b/view/frontend/templates/product/layered/tree/item.phtml
@@ -9,9 +9,16 @@ use Emico\Tweakwise\Block\LayeredNavigation\RenderLayered\TreeRenderer\ItemRende
/** @var $block ItemRenderer */
$item = $block->getItem();
+
+$catUrl = $block->escapeUrl($item->getUrl());
+
+if (strpos($catUrl, $block->getBaseUrl()) === false) {
+ $catUrl = $block->getBaseUrl() . $item->getUrl();
+}
+
?>
<li class="item">
- <a href="<?=$block->escapeUrl($item->getUrl())?>">
+ <a href="<?=$catUrl?>">
<?=$block->getItemPrefix()?>
<?=$block->escapeHtml($item->getLabel())?>
<?=$block->getItemPostfix()?>
@nwiegers01 Thanks for your comment and the provided path. It looks good. I've also tested it and it works accordingly. I will be merging it and releasing a new version: v4.0.6
Issue Brief
When we will open catalog page (PLP) we can see that links of child categories of the Tweakwise category tree in the layered navigation without baseUrl or at least without "/" at the beginning of the links that lead to 404 page if we will click on that links. As a solution I'm suggestion to add baseUrl for example in the viewmodel view/frontend/templates/product/layered/tree/item.phtml that will fix the issue. I can create PR if you agree with that.
Environment
Steps to reproduce
Actual result
Expected result