Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 6c59807
Merge: b087d6f 27b6967
Author: ah-net <[email protected]>
Date:   Tue Sep 24 14:39:53 2024 +0200

    Merge branch 'master' into beta

commit b087d6f
Merge: a63f1b7 cb61179
Author: ah-net <[email protected]>
Date:   Thu Sep 19 11:36:00 2024 +0200

    Merge pull request #33 from EmicoEcommerce/fix-bump-php-version

    Fix: bump php version

commit cb61179
Author: ah-net <[email protected]>
Date:   Thu Sep 19 11:15:24 2024 +0200

    fix: bump php version

commit a63f1b7
Merge: 7ce708c 15b7a61
Author: ah-net <[email protected]>
Date:   Thu Sep 19 10:55:54 2024 +0200

    Merge pull request #31 from EmicoEcommerce/fix-return-landingpage-url

    Fix: return landingpage url

commit 7ce708c
Merge: 69e0406 37a9fef
Author: ah-net <[email protected]>
Date:   Thu Sep 19 10:46:29 2024 +0200

    Merge pull request #32 from EmicoEcommerce/fix-select-attribute

    fix: selecting attribute doesn't update

commit 37a9fef
Author: ah-net <[email protected]>
Date:   Tue Sep 17 10:46:38 2024 +0200

    fix: selecting attribute

commit 15b7a61
Author: ah-net <[email protected]>
Date:   Fri Sep 13 13:18:12 2024 +0200

    Revert "Update RendererPlugin.php"

    This reverts commit b1d986b.

commit b1d986b
Author: ah-net <[email protected]>
Date:   Fri Sep 13 13:02:54 2024 +0200

    Update RendererPlugin.php

commit 9bd57b4
Author: ah-net <[email protected]>
Date:   Thu Jun 27 10:04:04 2024 +0200

    Remove space

commit ce621b2
Author: ah-net <[email protected]>
Date:   Thu Jun 27 10:01:38 2024 +0200

    Fix bug without ajax

commit d50ae96
Author: ah-net <[email protected]>
Date:   Fri Jun 21 11:10:43 2024 +0200

    fix: landing page url

commit 8bc79ac
Author: ah-net <[email protected]>
Date:   Thu Jun 20 10:14:35 2024 +0200

    fix: bug with landingpage url

commit 69e0406
Author: evs-xsarus <[email protected]>
Date:   Tue Apr 30 15:58:23 2024 +0200

    Make installable on PHP 8.x (#24)

    * fix: make installable on php 8.3

commit 9ac763e
Author: ah-net <[email protected]>
Date:   Tue Apr 30 15:42:25 2024 +0200

    fix: save tweakwise filter template

commit 103be57
Author: ah-net <[email protected]>
Date:   Tue Apr 30 15:41:50 2024 +0200

    chore: update version (#28)

    * chore: update version

    * chore: remove composer version

    * chore: support tweakwise 6.0

    * chore: support version 5.0 of attribute landing
  • Loading branch information
ah-net committed Sep 24, 2024
1 parent 27b6967 commit c9de69b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Provides compatibility between Attribute landing module and Tweakwise module.",
"license": "OSL-3.0",
"require": {
"php": "^8.0",
"php": "^8.1",
"tweakwise/magento2-tweakwise": ">=5.7.4",
"emico/m2-attributelanding": ">=4.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tweakwise\AttributeLandingTweakwise\Plugin\Block\LayeredNavigation\RenderLayered;

use Emico\AttributeLanding\Model\LandingPageContext;
use Tweakwise\AttributeLandingTweakwise\Model\FilterManager;
use Tweakwise\Magento2Tweakwise\Model\Catalog\Layer\Filter\Item;
use Magento\Framework\View\Element\Template;
Expand All @@ -16,13 +17,19 @@ class RendererPlugin
*/
protected $filterManager;

/**
* @var LandingPageContext
*/
protected $landingPageContext;

/**
* DefaultRendererPlugin constructor.
* @param FilterManager $filterManager
*/
public function __construct(FilterManager $filterManager)
public function __construct(FilterManager $filterManager, LandingPageContext $landingPageContext)
{
$this->filterManager = $filterManager;
$this->landingPageContext = $landingPageContext;
}

/**
Expand All @@ -36,7 +43,18 @@ public function afterRenderAnchorHtmlTagAttributes(
string $result,
Item $filterItem
) {
if (!$this->filterManager->findLandingPageUrlForFilterItem($filterItem)) {

$returnToDefaultPage = false;

$landingPage = $this->landingPageContext->getLandingPage();
if ($landingPage) {
$landingPageUrl = $landingPage->getUrlPath();
if (stripos($result, $landingPageUrl) === false) {
$returnToDefaultPage = true;
}
}

if (!$this->filterManager->findLandingPageUrlForFilterItem($filterItem) && !$returnToDefaultPage) {
return $result;
}

Expand Down
11 changes: 10 additions & 1 deletion src/Plugin/PathSlugStrategyPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ public function afterGetCategoryFilterSelectUrl(
*/
public function afterGetOriginalUrl(PathSlugStrategy $original, string $result, MagentoHttpRequest $request): string
{
return $result;
$landingPage = $this->landingPageContext->getLandingPage();
if ($landingPage === null) {
return $result;
}

if (strpos($result, $landingPage->getUrlPath()) !== false) {
return $result;
}

return $landingPage->getUrlPath();
}
}
4 changes: 3 additions & 1 deletion src/Plugin/UrlPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ public function aroundGetRemoveFilter(Url $subject, Closure $proceed, Item $filt
if (preg_match('|' . $landingPage->getUrlRewriteRequestPath() . '(.*)|', $removeUrl, $matches)) {
$category = $this->getLayer()->getCurrentCategory();
$categoryUrl = $category->getUrl();
$removeUrl = $categoryUrl . $matches[1];

//ensure there is one slash between category and the rest of the url
$removeUrl = rtrim($categoryUrl, '/') . '/' . ltrim($matches[1], '/');
}

return $removeUrl;
Expand Down
1 change: 1 addition & 0 deletions src/view/adminhtml/web/js/filter-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ define([
inputValue.show();
} else {
inputAttribute.hide();
selectValue.val(facetValue);
if (selectValue.val() != 'tw_other') {
inputValue.hide();
inputAttribute.val(facetValue);
Expand Down

0 comments on commit c9de69b

Please sign in to comment.