Skip to content

Commit

Permalink
Update PathSlugStrategyPlugin.php (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-net authored Dec 8, 2023
1 parent 72de013 commit 4ddca71
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Plugin/PathSlugStrategyPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Emico\AttributeLanding\Model\LandingPageContext;
use Tweakwise\AttributeLandingTweakwise\Model\FilterManager;
use Tweakwise\Magento2Tweakwise\Model\Catalog\Layer\Filter\Item;
use Tweakwise\Magento2Tweakwise\Model\Catalog\Layer\Url\Strategy\FilterSlugManager;
use Tweakwise\Magento2Tweakwise\Model\Catalog\Layer\Url\Strategy\PathSlugStrategy;
use Tweakwise\Magento2Tweakwise\Model\Catalog\Layer\UrlFactory;
use Magento\Framework\App\Request\Http as MagentoHttpRequest;
Expand All @@ -31,6 +32,11 @@ class PathSlugStrategyPlugin
*/
private $urlFactory;

/**
* @var FilterSlugManager
*/
private $filterSlugManager;

/**
* @param LandingPageContext $landingPageContext
* @param FilterManager $filterManager
Expand All @@ -40,11 +46,13 @@ class PathSlugStrategyPlugin
public function __construct(
LandingPageContext $landingPageContext,
FilterManager $filterManager,
UrlFactory $urlFactory
UrlFactory $urlFactory,
FilterSlugManager $filterSlugManager
) {
$this->landingPageContext = $landingPageContext;
$this->filterManager = $filterManager;
$this->urlFactory = $urlFactory;
$this->filterSlugManager = $filterSlugManager;
}

/**
Expand Down Expand Up @@ -159,10 +167,15 @@ public function afterGetCategoryFilterSelectUrl(
return $result;
}

$lookupTable = $this->filterSlugManager->getLookupTable();
$filters = [];
foreach ($landingsPageFilters as $filter) {
$filters[] = $filter->getFacet();
$filters[] = strtolower($filter->getValue());
if (!empty($lookupTable[$filter->getValue()])) {
$filters[] = $lookupTable[$filter->getValue()];
} else {
$filters[] = strtolower($filter->getValue());
}
}

return sprintf(
Expand Down

0 comments on commit 4ddca71

Please sign in to comment.