Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwindell committed Apr 20, 2023
1 parent bdae8cf commit 584e7f8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Model/Config/Source/StoreLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,7 @@ public function getAllStoresLang($obj = false)

try {
if ($type == 'category') {
$storeCategory = $this->categoryRepository->get($obj->getId(), $store->getId());
$selectedFilters = $this->layeredNavState->getActiveFilters();

$queryParams = [];
foreach($selectedFilters as $filter){
$queryParams [$filter->getFilter()->getRequestVar()] = $filter->getValue();
}
$storeCategory = $this->categoryRepository->get($obj->getId(), $store->getId());

if (!$storeCategory->getIsActive()) {
continue;
Expand All @@ -148,21 +142,28 @@ public function getAllStoresLang($obj = false)
UrlRewrite::STORE_ID => $store->getId(),
]
);

if ($rewrite) {
$urlPath = $rewrite->getRequestPath();
$langUlr = $store->getBaseUrl() . $urlPath;
} else {
$selectedFilters = $this->layeredNavState->getActiveFilters();

$queryParams = [];
foreach($selectedFilters as $filter){
$queryParams[$filter->getFilter()->getRequestVar()] = $filter->getValue();
}

$urlPath = $storeCategory->getUrlPath();
$langUlr = $store->getUrl($urlPath, ['_query' => $queryParams]);
}

if ($this->urlModifier) {
// Amasty Shopby
$this->storeManager->setCurrentStore($store->getStoreId()); // Set temporarily change store to get Amasty SEO Url for correct store view
// Amasty Shopby
$this->storeManager->setCurrentStore($store->getStoreId());
$langUlr = $this->urlModifier->execute($langUlr, $storeCategory->getId());
$this->storeManager->setCurrentStore($currentStoreId);
}

} elseif ($type == 'product') {
$storeProduct = $this->productRepository->getById($obj->getId(), false, $store->getId());

Expand All @@ -184,7 +185,6 @@ public function getAllStoresLang($obj = false)
$locale[$langPrefix] = $langUlr;
}
}
$this->storeManager->setCurrentStore($currentStoreId); // Reset store view back to current store (See Amasty section above)

return $locale;
}
Expand Down

0 comments on commit 584e7f8

Please sign in to comment.