Skip to content

Commit 8d0bbdb

Browse files
authored
Merge branch 'develop' into bugfix/3923
2 parents 3e801c9 + d293dbb commit 8d0bbdb

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
- Fixed edit shipping address in my account - @gibkigonzo (#3921)
4545
- Fetch cms_block content in serverPrefetch method - @gibkigonzo (#3910)
4646
- Fixed saving invalidated user token - @andrzejewsky (#3923)
47+
- Keep category products objects on ssr - @gibkigonzo (#3924)
4748

4849
### Changed / Improved
4950
- Changed pre commit hook to use NODE_ENV production to check for debugger statements - @resubaka (#3686)

core/modules/catalog-next/store/category/getters.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ import { _prepareCategoryPathIds, getSearchOptionsFromRouteParams } from '../../
1616
import { removeStoreCodeFromRoute } from '@vue-storefront/core/lib/multistore'
1717
import cloneDeep from 'lodash-es/cloneDeep'
1818

19-
function mapCategoryProducts (productsSkus, productsData) {
20-
return productsSkus.map(prodSku => {
21-
const product = productsData.find(prodData => prodData.sku === prodSku)
22-
return cloneDeep(product)
19+
function mapCategoryProducts (productsFromState, productsData) {
20+
return productsFromState.map(prodState => {
21+
if (typeof prodState === 'string') {
22+
const product = productsData.find(prodData => prodData.sku === prodState)
23+
return cloneDeep(product)
24+
}
25+
return prodState
2326
})
2427
}
2528

core/modules/catalog-next/store/category/mutations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isServer } from '@vue-storefront/core/helpers';
12
import { nonReactiveState } from './index';
23
import Vue from 'vue'
34
import { MutationTree } from 'vuex'
@@ -9,11 +10,11 @@ import cloneDeep from 'lodash-es/cloneDeep'
910
const mutations: MutationTree<CategoryState> = {
1011
[types.CATEGORY_SET_PRODUCTS] (state, products = []) {
1112
nonReactiveState.products = cloneDeep(products)
12-
state.products = products.map(prod => prod.sku)
13+
state.products = isServer ? products : products.map(prod => prod.sku)
1314
},
1415
[types.CATEGORY_ADD_PRODUCTS] (state, products = []) {
1516
nonReactiveState.products.push(...cloneDeep(products))
16-
state.products.push(...products.map(prod => prod.sku))
17+
state.products.push(...(isServer ? products : products.map(prod => prod.sku)))
1718
},
1819
[types.CATEGORY_ADD_CATEGORY] (state, category: Category) {
1920
if (category) {

0 commit comments

Comments
 (0)