Skip to content

Commit

Permalink
Merge pull request #6052 from vuestorefront/#5871/redirect-nonexistin…
Browse files Browse the repository at this point in the history
…g-category

Redirect to 404 page when category does not exist
  • Loading branch information
lukaszjedrasik authored Aug 25, 2021
2 parents 37c21df + 3c39655 commit e50c7b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/core/docs/changelog/5871.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
description: 'Redirect to 404 page when category page does not exist',
link: 'https://github.com/vuestorefront/vue-storefront/issues/5871',
isBreaking: false,
breakingChanges: [],
author: 'Łukasz Jędrasik',
linkToGitHubAccount: 'https://github.com/lukaszjedrasik'
};
5 changes: 3 additions & 2 deletions packages/core/nuxt-theme-module/theme/pages/Category.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<span class="products__show-on-page__label">{{ $t('Show on page') }}</span>
<LazyHydrate on-interaction>
<SfSelect
:value="pagination.itemsPerPage.toString()"
:value="pagination && pagination.itemsPerPage ? pagination.itemsPerPage.toString() : ''"
class="products__items-per-page"
@input="th.changeItemsPerPage"
>
Expand Down Expand Up @@ -372,7 +372,7 @@ export default {
const uiState = useUiState();
const { addItem: addItemToCart, isInCart } = useCart();
const { addItem: addItemToWishlist, isInWishlist, removeItem: removeItemFromWishlist } = useWishlist();
const { result, search, loading } = useFacet();
const { result, search, loading, error } = useFacet();
const products = computed(() => facetGetters.getProducts(result.value));
const categoryTree = computed(() => facetGetters.getCategoryTree(result.value));
Expand Down Expand Up @@ -405,6 +405,7 @@ export default {
onSSR(async () => {
await search(th.getFacetsFromURL());
if (error?.value?.search) context.root.$nuxt.error({ statusCode: 404 });
setSelectedFilters();
});
Expand Down

0 comments on commit e50c7b1

Please sign in to comment.