Closed timdk closed 4 years ago
I change in my local source core/modules/cms/helpers/createSinglePageLoadQuery.ts
Line 7 to
// query = query.applyFilter({ key, value: { like: value } })
query = query.applyFilter({ key, value: { eq: value } })
And CMS page work OK in Capybara theme
@TTomas maybe you could create a PR with this fix? would be great!
@pkarw I can do it, should I target hotfix or master? Edit: I see it's assigned to hotfix 1.12.3
@timdk please aim at the 1.12.3 thanks!
It should be handled by this line. https://github.com/DivanteLtd/storefront-query-builder/blob/0ef1f9760eb44edce5b9464a9145ce0a7517a419/src/elasticsearch/body.ts#L224 Please check if you have newest storefront-query-builder @timdk
@gibkigonzo you are right, I set up project after June 10 but my yarn.lock is pulling commit 3984d39 before this line was added. The commit has has since been updated in this repo... just bad timing I guess!
I'll close this PR then! Thanks for your attention
Current behavior
In short: When querying a CMS Block by its identifier, the query filters are not applied properly. This means the Block component is empty on the storefront.
In detail: When using the default CMS Block component in the default theme to insert a component using its identifier, the
createSingleBlockQuery()
helper builds a query using thelike
operator:https://github.com/DivanteLtd/vue-storefront/blob/master/core/modules/cms/helpers/createSingleBlockQuery.ts#L7
This operator is also used when building queries for CMS Pages.
This operator is not handled in the storefront-query-builder package as one of the
baseFilters
. https://github.com/DivanteLtd/storefront-query-builder/blob/master/src/elasticsearch/body.ts#L75This means the check inside the inner loop of
applyBaseFilters()
always fails and the filter is not applied onto bodybuilder queryChain. https://github.com/DivanteLtd/storefront-query-builder/blob/master/src/elasticsearch/body.ts#L216When the request is made it doesn't have any filters so the response contains all (or top 50) bocks and only the first result is committed into the vuex store by the action. https://github.com/DivanteLtd/vue-storefront/blob/master/core/modules/cms/store/block/actions.ts#L38
In my case the first result is the wrong component. Nothing is returned by the state store and on my storefront the component is blank. https://github.com/DivanteLtd/vsf-default/blob/master/components/core/blocks/Cms/Block.vue#L62
Expected behavior
I am not sure what the best solution here is but I can see two options
like
to use theeq
operator insteadlike
operator to the storefront-query-projectI have fixed the issue locally with the first change but maybe the second is a better solution.
Steps to reproduce the issue
It's a little hard to provide a repo because it depends on the data and a full end-to-end magento/VSF configuration.
Block.vue
component add your block by its identifier e.g.<Block identifier="footer_col_1" />
NB: If by chance the correct block is returned as the first result of an unfiltered query, it will 'just work' so you may need to experiment with several identifiers to reproduce the issue.
Version of Vue Storefront
Can you handle fixing this bug by yourself?
I can open a PR if a member of the core team identifies solution 1. above as the preferred approach.
Which Release Cycle state this refers to? Info for developer. (doesn't apply to Next)
Pick one option.
develop
branch and create Pull Request2. Feature / Improvement
back todevelop
.release
branch and create Pull Request3. Stabilisation fix
back torelease
.hotfix
ormaster
branch and create Pull Request4. Hotfix
back tohotfix
.Environment details
Additional information
n/a