-
Notifications
You must be signed in to change notification settings - Fork 103
feat(snippets): initial concept for snippet handling. #945
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/shopware-pwa/shopware-pwa-docs/ou19c057m |
Seems good! Maybe add an option to |
That's actually a good idea! That would allow for different snippet sets per project rather easily. Adding it to checklist. |
Added documentation for the command - it contains some matters to discuss. - https://shopware-pwa-docs-git-feat-snippet-handling-cli.shopware-pwa.vercel.app/landing/concepts/snippets.html#management-in-shopware |
Well done Dominic! It all makes sense to me. Do you have any doubts about some parts of the implementation? |
@Rigo-m, generally I'm fine with the concept, but it still lacks support for some complexities we could encounter, such as: Multiple snippet sets for one language (you can configure different snippet sets for different shops, both based on the same locale). For example if you want to call it "Shopping Cart" within one Store (Sales Channel) and "My Basket" in the other one. We're currently using the locales to map the snippet sets and this will work in 99% of all the cases. However if we have the specific scenario outlined above, it fails to map the snippets correctly. Hence, a proper solution would need to do the matching by snippet set ID instead of locale. This also means, that we need to refactor the This will lead to a third point of issue which is the routing. We are using the language locale for routing within PWA, by prefixing every route with
So instead, we need to take the domains from the Sales Channel as a "base" of our routing together with the corresponding snippet sets. And based off those root domains we can do the routing per Sales Channel (language). /cc @patzick . |
So how would the routing change based on the latest consideration? I understand that shopware's internals are very well suited for multiple sales channel and multiple frontends, but since we are basically giving the developer the power to create snippets (since the end user will have to work with pwa's exported snippets and pwa is the source of truth) why not stick, for this case, for convention over configuration? |
If we follow that path, we just have to make sure to be aware of that redundancy we introduce, because PWA won't reflect the domain configuration of your sales channel in Shopware but your language configuration instead. In that way it would functionally diverge from our default storefront implementation and at some point lead to confusion. For people relying on that very functionality. I do appreciate your point of convention over configuration and using PWA as a "source of truth" for snippet management. This will allow us to decouple PWA from the sales channel configuration and also keep the locale codes as our primary identifier. If we go down the path that you propose that will include less refactoring, but we'll keep this bit of architectural (debt/inconsistency) which we'll probably have to revise at a later stage. We'll discuss those points tomorrow during our weekly and share the outcomes here. I think Patryk also has some thoughts on that which he'd like to share. |
💙 shopware-pwa-canary successfully deployed at https://a767417be8265893b74e1e3b621eb7a3876839bd.shopware-pwa-canary.preview.storefrontcloud.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
Changes
Provides snippets support for Shopware PWA
shopware-pwa snippets
will only import snippets from Shopware and append them to your project locale file.IMPORTANT You cannot create snippets from the admin and import them into the PWA.
First they have to be created within your locales/[iso-code].json file and exported to Shopware.
shopware-pwa languages
shopware-pwa snippets --export --username="admin" --password="shopware"
shopware-pwa snippets
again to fetch those.--export
Checklist
I followed contributing guidelines
Error Handling
Hooking into the init process
Documentation
After Call with @patzick and @mkucmus
using--pwa-first
--keep-local
instead)locales
directoryProposed by @Rigo-m
pwa.