Skip to content

Update develop/1.12.1 #4569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 113 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
3aa71e8
[Docs] Updated archives/vuex added
kkdg Apr 8, 2020
7ad76d6
[Docs] Updated cookbook/devops updates
kkdg Apr 8, 2020
3e8a1ea
[Docs] Updated vuex/introduction fix
kkdg Apr 8, 2020
9f0149c
Merge remote-tracking branch 'origin2/master'
kkdg Apr 8, 2020
762e309
[Docs] Updated header link for blog
kkdg Apr 21, 2020
4e1307a
Merge remote-tracking branch 'origin2/master'
kkdg May 8, 2020
563552f
[Docs] Updated basics/graphql deprecated
kkdg May 20, 2020
c012c8b
Update deploy-storefrontcloud.yml
May 27, 2020
e4223fc
Merge pull request #4474 from DivanteLtd/gibkigonzo-patch-1
May 27, 2020
3a6f12e
fix price and attributes
May 27, 2020
db02543
Update integrations to add Fresh Relevance
dhendo May 27, 2020
4efc955
calc price for grouped and bundle product
May 27, 2020
d35ab5b
revert productAfterCustomoptions calc
May 27, 2020
7c1b27e
add reactivness to shipping address
May 27, 2020
712427e
update price format
May 28, 2020
99c61da
Merge pull request #4476 from gibkigonzo/bugfix/release-1.12
May 28, 2020
de3eb96
change value to number in price filter
May 28, 2020
2ab8cc9
Merge pull request #4478 from gibkigonzo/bugfix/prevent-null-price
May 28, 2020
9877196
update information about deprecated actions
May 28, 2020
6de6fb1
Merge pull request #4479 from gibkigonzo/update-deprecated-info
May 28, 2020
4baaa29
udpate yarn and filter shipping methods for instant checkout
May 28, 2020
ad6e958
use currentRoute params
May 28, 2020
c2148a3
Merge pull request #4480 from gibkigonzo/bugfix/update-yarn
May 28, 2020
ca23bfc
convert option ids to string
May 29, 2020
d187005
update changelog
May 29, 2020
1484bf9
move deprecated code to files
May 29, 2020
44a42f9
update ugrade notes
May 29, 2020
e5030f8
update changelog
May 29, 2020
1cedd4e
bump version
May 29, 2020
40075ae
Merge pull request #4484 from gibkigonzo/bugfix/update-getProductConf…
May 29, 2020
d5a2f41
Merge branch 'release/v1.12.0-rc.1' into feature/move-deprecated-code…
May 29, 2020
f0b81d2
Merge pull request #4485 from gibkigonzo/feature/move-deprecated-code…
May 29, 2020
6de4a07
Remove categories with unknown `url_path` from breadcrumbs
jissereitsma May 29, 2020
d1921aa
add attribute metadata to api-search-query
Jun 1, 2020
e88393c
add parentId
Jun 1, 2020
5319c67
return if no current product
Jun 1, 2020
98b272f
update changelog
Jun 1, 2020
72070e1
update @babel/preset-env
Jun 1, 2020
c4254ff
Merge pull request #4491 from gibkigonzo/bugfix/add-attributeMetadata…
Jun 1, 2020
42f9087
Merge remote-tracking branch '@vue-storefront/release/v1.12.0-rc.1' i…
Jun 1, 2020
01618fb
Merge remote-tracking branch '@vue-storefront/release/v1.12.0-rc.1' i…
Jun 1, 2020
c80a135
Merge pull request #4493 from DivanteLtd/release/v1.12
Jun 2, 2020
4392f51
add default theme repo
Jun 2, 2020
e6480c5
update config
Jun 2, 2020
42821a4
remo --quiet from git clone
Jun 2, 2020
d04b90f
Merge pull request #4494 from DivanteLtd/gibkigonzo-patch-2
Jun 2, 2020
7ba4b91
use config.i18n.defaultLocale as fallback locale
Jun 3, 2020
c941bac
update changelog
Jun 3, 2020
4a63159
update changelog
Jun 3, 2020
df81cfc
create abs price before toLocaleString
Jun 5, 2020
aaa38b8
revert toFixed changes and use .abs on value
Jun 5, 2020
05fd832
update changelog
Jun 5, 2020
ba2a685
Fix typo
ThermScissorpunch Jun 8, 2020
2f03887
separate theme installation
Jun 11, 2020
27237e2
update docs: theme installation
Jun 11, 2020
d64f152
update skip task and docker sh
Jun 11, 2020
7a57ee2
update info in theme-path
Jun 11, 2020
cca675e
Docs update - note on not exposing the API endpoints
pkarw Jun 12, 2020
f019aa8
add directory step
Jun 12, 2020
f17a65d
Merge pull request #4538 from DivanteLtd/pkarw-patch-1
pkarw Jun 12, 2020
edcec67
Merge branch 'master' into master
pkarw Jun 13, 2020
dfdb9f5
Merge pull request #4350 from kkdg/master
pkarw Jun 13, 2020
7d5ede7
add purge-config loader
gibkigonzo Jun 14, 2020
be60418
update changelog
gibkigonzo Jun 14, 2020
f5f9a96
clear vuex warnings
gibkigonzo Jun 14, 2020
d010d44
update changelog
gibkigonzo Jun 14, 2020
084f408
Merge pull request #4503 from gibkigonzo/bugfix/4489
Jun 14, 2020
21c6f9a
Merge branch 'hotfix/v1.12.1' into feature/add-purgeConfig
Jun 14, 2020
405e8bf
update changelog
gibkigonzo Jun 14, 2020
a733d4f
Merge pull request #4540 from gibkigonzo/feature/add-purgeConfig
Jun 14, 2020
7f2e23e
Merge branch 'hotfix/v1.12.1' of github.com:DivanteLtd/vue-storefront…
Jun 15, 2020
2008582
add tofixed for non locale price
Jun 15, 2020
2a27364
Merge pull request #4523 from gibkigonzo/bugfix/4521
Jun 15, 2020
5d23ba2
move create task after prompt
Jun 15, 2020
cdd925c
use _installationDir
Jun 15, 2020
ca85259
use _installationDir
Jun 15, 2020
dd7bb0e
Merge branch 'hotfix/v1.12.1' into feature/separate-theme-install
Jun 16, 2020
9a9c92c
Merge pull request #4534 from gibkigonzo/feature/separate-theme-install
Jun 16, 2020
6739977
Merge branch 'hotfix/v1.12.1' into bugfix/clear-vuex-warning
Jun 16, 2020
0f28c1b
Load attributes data of attribute-meta for bundled and grouped products
Jun 16, 2020
e97c7ce
Only load products meta-data if `loadByAttributeMetadata` is enabled
Jun 16, 2020
be25c00
Update CHANGELOG.md
Jun 16, 2020
7169075
Change name of `setAttributesMetaFromProducts` to `getAttributesFromM…
Jun 16, 2020
53dee96
Merge branch 'hotfix/v1.12.1' into feature/load-meta-attributes-for-p…
Jun 16, 2020
3dca6c8
udpate execa and fix problem on windows
Jun 16, 2020
8146aa7
add clear cache to install
Jun 16, 2020
52b237d
update changelog
Jun 16, 2020
2bd45c2
Update integrations to add Fresh Relevance
dhendo May 27, 2020
6c085fe
Merge branch 'patch-2' of github.com:dhendo/vue-storefront into patch-2
dhendo Jun 16, 2020
6b2b97b
Update CHANGELOG.md
Jun 16, 2020
3c1fbf4
Merge branch 'master' into patch-2
jissereitsma Jun 16, 2020
cbdc268
Merge branch 'hotfix/v1.12.1' into patch-2
jissereitsma Jun 16, 2020
1cff83b
Merge pull request #4552 from gibkigonzo/bugfix/update-execa
Jun 17, 2020
8f00549
Merge branch 'master' into hotfix/v1.12.1
pkarw Jun 17, 2020
bf9d875
Merge branch 'hotfix/v1.12.1' into patch-2
Jun 17, 2020
53bafb3
Merge branch 'hotfix/v1.12.1' into patch-2
Jun 17, 2020
8c4af11
Merge pull request #4475 from dhendo/patch-2
Jun 17, 2020
a61cb4f
Merge branch 'hotfix/v1.12.1' into patch-4
Jun 17, 2020
5404fb4
Merge pull request #4525 from ThermScissorpunch/patch-4
Jun 17, 2020
2b41b78
Merge branch 'hotfix/v1.12.1' into feature/load-meta-attributes-for-p…
Jun 17, 2020
5f9b4b6
Merge branch 'hotfix/v1.12.1' into bugfix/clear-vuex-warning
Jun 17, 2020
759870b
Merge pull request #4551 from icmaa/feature/load-meta-attributes-for-…
Jun 17, 2020
903b5ff
Merge branch 'hotfix/v1.12.1' into bugfix/clear-vuex-warning
Jun 17, 2020
a0bf293
Merge pull request #4541 from gibkigonzo/bugfix/clear-vuex-warning
Jun 17, 2020
ccf91b1
Merge branch 'hotfix/v1.12.1' into patch-2
Jun 17, 2020
af2d1a1
Fix check in Travis
jissereitsma Jun 17, 2020
2f6dce1
Merge pull request #4488 from jissereitsma/patch-2
Jun 18, 2020
1d890b8
update theme installation link in docs
Jun 18, 2020
b19f229
Merge pull request #4565 from gibkigonzo/bugfix/4554
pkarw Jun 19, 2020
7c334c6
bump version
Jun 22, 2020
20c134c
add cloudflare to purgeConfig
Jun 22, 2020
4318282
Merge pull request #4568 from gibkigonzo/bump-version/1.12.1
Jun 22, 2020
09ef606
Merge pull request #4547 from DivanteLtd/hotfix/v1.12.1
Jun 22, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/deploy-storefrontcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Add theme
run: |
git clone --single-branch --branch master https://github.com/DivanteLtd/vsf-default.git ./src/themes/default
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "10.x"
- name: Create config file
run: |
echo '{"server":{"useOutputCacheTagging":true,"useOutputCache":true,"dynamicConfigReload":true},"api":{"url":"https://demo.storefrontcloud.io"}}' > config/local-cloud-demo.json
echo '{"server":{"useOutputCacheTagging":true,"useOutputCache":true,"dynamicConfigReload":true},"api":{"url":"https://demo.storefrontcloud.io"}}' > config/local-cloud-next.json
echo '{"server":{"useOutputCacheTagging":true,"useOutputCache":true,"dynamicConfigReload":true},"api":{"url":"https://test.storefrontcloud.io"}}' > config/local-cloud-test.json
echo '{"server":{"useOutputCacheTagging":true,"useOutputCache":true,"dynamicConfigReload":true},"api":{"url":"https://demo.storefrontcloud.io"},"elasticsearch":{"index":"vue_storefront_magento_1"},"entities":{"attribute":{"loadByAttributeMetadata":true}},"urlModule":{"enableMapFallbackUrl":true}}' > config/local-cloud-demo.json
echo '{"server":{"useOutputCacheTagging":true,"useOutputCache":true,"dynamicConfigReload":true},"api":{"url":"https://demo.storefrontcloud.io"},"elasticsearch":{"index":"vue_storefront_magento_1"},"entities":{"attribute":{"loadByAttributeMetadata":true}},"urlModule":{"enableMapFallbackUrl":true}}' > config/local-cloud-next.json
echo '{"server":{"useOutputCacheTagging":true,"useOutputCache":true,"dynamicConfigReload":true},"api":{"url":"https://test.storefrontcloud.io"},"elasticsearch":{"index":"vue_storefront_magento_1"},"entities":{"attribute":{"loadByAttributeMetadata":true}},"urlModule":{"enableMapFallbackUrl":true}}' > config/local-cloud-test.json
- name: Build and publish docker image
uses: elgohr/Publish-Docker-Github-Action@master
with:
Expand Down Expand Up @@ -85,4 +88,4 @@ jobs:
target_url: https://demo.storefrontcloud.io
description: Unfortunately, the instance hasn't been updated.
state: "failure"
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.12.0-rc1] - UNRELEASED
## [1.12.1] - 2020.06.22

### Added

- Add `purgeConfig` to default.json and purge-config loader - @gibkigonzo (#4540)
- Load attributes data of attribute-meta for bundled and grouped products - @cewald (#4551)
- Separate theme installation and add it as yarn init:theme or as a step in yarn installer. - @gibkigonzo (4534, #4552)

### Fixed

- use `config.i18n.defaultLocale` as fallback locale instead of `'en-US'` - @gibkigonzo (#4489)
- use Math.abs on raw price - @gibkigonzo (#4521)
- Clears vuex warnings about overriding state by module - @gibkigonzo (#4541)

### Changed / Improved

## [1.12.0] - 2020.06.01

### Added

Expand Down Expand Up @@ -61,6 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- removed possible memory leak in ssr - @resubaka (#4247)
- Bugfix for reactivity of `current_configuration` in `populateProductConfigurationAsync` - @cewald (#4258)
- Bugfix for build exception in Node v13.13+ - @cewald (#4249)
- Convert option ids to string while comparing them in `getProductConfiguration` - @gibkigonzo (#4484)
- change value to number in price filter - @gibkigonzo (#4478)

### Changed / Improved

Expand All @@ -79,6 +97,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Homepage, new products query, uses now `new` attribute - @mdanilwoicz
- Refactor product module, more info in upgrade notes- @gibkigonzo (#3952, #4459)
- Move default theme to separate repository https://github.com/DivanteLtd/vsf-default - @gibkigonzo (#4255)
- add two numbers after dot to price by default, calculate default price for bundle or grouped main product, update typing, add fallback to attribute options - @gibkigonzo (#4476)
- udpate yarn and filter shipping methods for instant checkout - @gibkigonzo (#4480)
- add attribute metadata search query, add parentId - @gibkigonzo (#4491)

## [1.11.4] - 2020.05.26

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ You can find some tutorials and explanations on our [YouTube channel](https://ww
- [Starter pack for install](https://docs.vuestorefront.io/guide/cookbook/setup.html)
- [Installing on Linux/MacOS](https://docs.vuestorefront.io/guide/installation/linux-mac.html)
- [Installing on Windows](https://docs.vuestorefront.io/guide/installation/windows.html)
- [Installing theme](https://docs.vuestorefront.io/guide/installation/theme.html)
- [How to install and integrate with Magento2](https://docs.vuestorefront.io/guide/installation/magento.html)
- [Production setup](https://docs.vuestorefront.io/guide/installation/production-setup.html)

Expand Down
14 changes: 13 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -871,5 +871,17 @@
},
"varnish": {
"enabled":false
}
},
"purgeConfig": [
"server.invalidateCacheKey",
"server.invalidateCacheForwardUrl",
"server.trace",
"redis",
"install",
"expireHeaders",
"fastly",
"nginx",
"varnish",
"cloudflare"
]
}
16 changes: 16 additions & 0 deletions core/build/purge-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const omit = require('lodash/omit')

/**
* clear config properties that shouldn't be visible on frontend
*/
module.exports = function loader(source) {
let config = JSON.parse(source);

const purgeConfig = (config.purgeConfig || []).slice()

config = omit(config, purgeConfig)

delete config['purgeConfig']

return JSON.stringify(config);
}
4 changes: 1 addition & 3 deletions core/build/theme-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ else {
if(!fs.existsSync(themePath)) {
console.error(`
The theme you want to use does not exist.
Please use 'vsf init' or install manualy one of our official themes:
- https://github.com/DivanteLtd/vsf-capybara#--installation
- https://github.com/DivanteLtd/vsf-default#--installation
Please check theme installation: https://docs.vuestorefront.io/guide/installation/theme.html
`)
process.exit(1)
}
Expand Down
4 changes: 4 additions & 0 deletions core/build/webpack.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ export default {
test: /\.(graphqls|gql)$/,
exclude: /node_modules/,
loader: ['graphql-tag/loader']
},
{
test: /core\/build\/config\.json$/,
loader: path.resolve('core/build/purge-config.js')
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions core/filters/price.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export function price (value, storeView) {
}
const _storeView = storeView || currentStoreView();
if (!_storeView.i18n) {
return value;
return Number(value).toFixed(2)
}

const { defaultLocale, currencySign, currencyDecimal, currencyGroup, fractionDigits, priceFormat } = _storeView.i18n;

const options = { minimumFractionDigits: fractionDigits, maximumFractionDigits: fractionDigits };

let localePrice = Math.abs(value.toLocaleString(defaultLocale, options));
let localePrice = Math.abs(value).toLocaleString(defaultLocale, options);

if (currencyDecimal !== '' || currencyGroup !== '') {
localePrice = replaceSeparators(localePrice, { decimal: currencyDecimal, group: currencyGroup }, getLocaleSeparators(defaultLocale));
Expand Down
9 changes: 5 additions & 4 deletions core/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ once('__VUE_EXTEND_I18N__', () => {
Vue.use(VueI18n)
})

const loadedLanguages = ['en-US']
const defaultLocale = config.i18n.defaultLocale || 'en-US'
const loadedLanguages = [defaultLocale]
const i18n = new VueI18n({
locale: config.i18n.bundleAllStoreviewLanguages ? config.i18n.defaultLocale : 'en-US', // set locale
fallbackLocale: 'en-US',
locale: defaultLocale, // set locale
fallbackLocale: defaultLocale,
messages: config.i18n.bundleAllStoreviewLanguages ? require('./resource/i18n/multistoreLanguages.json') : {
'en-US': require('./resource/i18n/en-US.json')
[defaultLocale]: require(`./resource/i18n/${defaultLocale}.json`)
}
})

Expand Down
2 changes: 1 addition & 1 deletion core/i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue-storefront/i18n",
"version": "1.11.4",
"version": "1.12.1",
"description": "Vue Storefront i18n",
"license": "MIT",
"main": "index.ts",
Expand Down
4 changes: 2 additions & 2 deletions core/i18n/scripts/translation.preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function convertToObject (array) {

module.exports = function (csvDirectories, config = null) {
const currentLocales = currentBuildLocales()
const fallbackLocale = 'en-US'
const fallbackLocale = config.i18n.defaultLocale || 'en-US'
let messages = {}
let languages = []

Expand All @@ -43,7 +43,7 @@ module.exports = function (csvDirectories, config = null) {

// create fallback
console.debug(`Writing JSON file fallback: ${fallbackLocale}.json`)
fs.writeFileSync(path.join(__dirname, '../resource/i18n', `${fallbackLocale}.json`), JSON.stringify(messages[fallbackLocale]))
fs.writeFileSync(path.join(__dirname, '../resource/i18n', `${fallbackLocale}.json`), JSON.stringify(messages[fallbackLocale] || {}))

// bundle all messages in one file
if (config && config.i18n.bundleAllStoreviewLanguages) {
Expand Down
5 changes: 4 additions & 1 deletion core/lib/multistore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export async function prepareStoreView (storeCode: string): Promise<StoreView> {
if (storeView.storeCode && config.storeViews.multistore === true && config.storeViews[storeView.storeCode]) {
storeView = merge(storeView, getExtendedStoreviewConfig(config.storeViews[storeView.storeCode]))
}
rootStore.state.user.current_storecode = storeView.storeCode

if (rootStore.state.user) {
rootStore.state.user.current_storecode = storeView.storeCode
}

if (storeViewHasChanged) {
storeView = coreHooksExecutors.beforeStoreViewChanged(storeView)
Expand Down
1 change: 1 addition & 0 deletions core/lib/search/adapter/api-search-query/searchAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class SearchAdapter {
start: start,
perPage: size,
aggregations: resp.aggregations,
attributeMetadata: resp.attribute_metadata,
suggestions: resp.suggest
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/mixins/onBottomScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const isBottomVisible = () => {
}

/**
* By implementing this mixin add "onBottomScroll" mthod in component.
* By implementing this mixin add "onBottomScroll" method in component.
* It will be invoked when view reach the bottom.
*/
export default {
Expand Down
1 change: 1 addition & 0 deletions core/modules/breadcrumbs/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { formatCategoryLink } from '@vue-storefront/core/modules/url/helpers'
export function parseCategoryPath (categoryPath) {
let routesArray = []
for (let category of categoryPath) {
if (category.url_path === undefined || category.url_path === null) continue;
routesArray.push({
name: category.name,
route_link: formatCategoryLink(category)
Expand Down
2 changes: 1 addition & 1 deletion core/modules/cart/helpers/getProductConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ATTRIBUTES = ['color', 'size']
const getProductConfiguration = (product: CartItem): ProductConfiguration => {
const options = getProductOptions(product)
const getAttributesFields = (attributeCode) =>
(options[attributeCode] || []).find(c => c.id === parseInt(product[attributeCode]))
(options[attributeCode] || []).find(c => String(c.id) === String(product[attributeCode]))

if (!options) {
return null
Expand Down
47 changes: 5 additions & 42 deletions core/modules/catalog-next/store/category/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ import * as types from './mutation-types'
import RootState from '@vue-storefront/core/types/RootState'
import CategoryState from './CategoryState'
import { quickSearchByQuery } from '@vue-storefront/core/lib/search'
import { buildFilterProductsQuery, isServer } from '@vue-storefront/core/helpers'
import { buildFilterProductsQuery } from '@vue-storefront/core/helpers'
import { router } from '@vue-storefront/core/app'
import { currentStoreView, localizedDispatcherRoute, localizedDispatcherRouteName } from '@vue-storefront/core/lib/multistore'
import { localizedDispatcherRoute } from '@vue-storefront/core/lib/multistore'
import FilterVariant from '../../types/FilterVariant'
import { CategoryService } from '@vue-storefront/core/data-resolver'
import { changeFilterQuery } from '../../helpers/filterHelpers'
import { products, entities } from 'config'
import { configureProductAsync } from '@vue-storefront/core/modules/catalog/helpers'
import { DataResolver } from 'core/data-resolver/types/DataResolver';
import { Category } from '../../types/Category';
import { _prepareCategoryPathIds } from '../../helpers/categoryHelpers';
import { prefetchStockItems } from '../../helpers/cacheProductsHelper';
import { preConfigureProduct } from '@vue-storefront/core/modules/catalog/helpers/search'
import chunk from 'lodash-es/chunk'
import omit from 'lodash-es/omit'
import cloneDeep from 'lodash-es/cloneDeep'
Expand Down Expand Up @@ -121,43 +119,6 @@ const actions: ActionTree<CategoryState, RootState> = {
}
}
},
/**
* Calculates products taxes
* Registers URLs
* Configures products
*/
async processCategoryProducts ({ dispatch, rootState }, { products = [], filters = {} } = {}) {
dispatch('registerCategoryProductsMapping', products) // we don't need to wait for this
const configuredProducts = await dispatch('configureProducts', { products, filters })
return dispatch('tax/calculateTaxes', { products: configuredProducts }, { root: true })
},
/**
* Configure configurable products to have first available options selected
* so they can be added to cart/wishlist/compare without manual configuring
*/
async configureProducts ({ rootState }, { products = [], filters = {}, populateRequestCacheTags = config.server.useOutputCacheTagging } = {}) {
return products.map(product => {
product = Object.assign({}, preConfigureProduct({ product, populateRequestCacheTags }))
const configuredProductVariant = configureProductAsync({ rootState, state: { current_configuration: {} } }, { product, configuration: filters, selectDefaultVariant: false, fallbackToDefaultWhenNoAvailable: true, setProductErorrs: false })
return Object.assign(product, omit(configuredProductVariant, ['visibility']))
})
},
async registerCategoryProductsMapping ({ dispatch }, products = []) {
const { storeCode, appendStoreCode } = currentStoreView()
await Promise.all(products.map(product => {
const { url_path, sku, slug, type_id } = product
return dispatch('url/registerMapping', {
url: localizedDispatcherRoute(url_path, storeCode),
routeData: {
params: {
parentSku: product.parentSku || product.sku,
slug
},
'name': localizedDispatcherRouteName(type_id + '-product', storeCode, appendStoreCode)
}
}, { root: true })
}))
},
async findCategories (context, categorySearchOptions: DataResolver.CategorySearchOptions): Promise<Category[]> {
return CategoryService.getCategories(categorySearchOptions)
},
Expand Down Expand Up @@ -299,7 +260,9 @@ const actions: ActionTree<CategoryState, RootState> = {
}, { root: true })
}
}
}
},
/** Below actions are not used from 1.12 and can be removed to reduce bundle */
...require('./deprecatedActions').default
}

export default actions
47 changes: 47 additions & 0 deletions core/modules/catalog-next/store/category/deprecatedActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { currentStoreView, localizedDispatcherRoute, localizedDispatcherRouteName } from '@vue-storefront/core/lib/multistore'
import { preConfigureProduct } from '@vue-storefront/core/modules/catalog/helpers/search'
import omit from 'lodash-es/omit'
import config from 'config'
const { configureProductAsync } = require('@vue-storefront/core/modules/catalog/helpers')

const actions = {
/**
* Calculates products taxes
* Registers URLs
* Configures products
*/
async processCategoryProducts ({ dispatch, rootState }, { products = [], filters = {} } = {}) {
dispatch('registerCategoryProductsMapping', products) // we don't need to wait for this
const configuredProducts = await dispatch('configureProducts', { products, filters })
return dispatch('tax/calculateTaxes', { products: configuredProducts }, { root: true })
},
/**
* Configure configurable products to have first available options selected
* so they can be added to cart/wishlist/compare without manual configuring
*/
async configureProducts ({ rootState }, { products = [], filters = {}, populateRequestCacheTags = config.server.useOutputCacheTagging } = {}) {
return products.map(product => {
product = Object.assign({}, preConfigureProduct({ product, populateRequestCacheTags }))
const configuredProductVariant = configureProductAsync({ rootState, state: { current_configuration: {} } }, { product, configuration: filters, selectDefaultVariant: false, fallbackToDefaultWhenNoAvailable: true, setProductErorrs: false })
return Object.assign(product, omit(configuredProductVariant, ['visibility']))
})
},
async registerCategoryProductsMapping ({ dispatch }, products = []) {
const { storeCode, appendStoreCode } = currentStoreView()
await Promise.all(products.map(product => {
const { url_path, sku, slug, type_id } = product
return dispatch('url/registerMapping', {
url: localizedDispatcherRoute(url_path, storeCode),
routeData: {
params: {
parentSku: product.parentSku || product.sku,
slug
},
'name': localizedDispatcherRouteName(type_id + '-product', storeCode, appendStoreCode)
}
}, { root: true })
}))
}
}

export default actions
2 changes: 1 addition & 1 deletion core/modules/catalog-next/store/category/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const getters: GetterTree<CategoryState, RootState> = {
}) || {}
},
getCurrentCategory: (state, getters, rootState, rootGetters) => {
return getters.getCategoryByParams(rootState.route.params)
return getters.getCategoryByParams({ ...rootGetters['url/getCurrentRoute'].params })
},
getAvailableFiltersFrom: (state, getters, rootState) => (aggregations) => {
const filters = {}
Expand Down
Loading