We'll take a look at setting up Shopware PWA, as well as how to create a plugin that fetches product recommendations. All without touching the Shopware Backend.
9. What's in the box
CLI
$ shopware-pwa …
• build creates the build for production
• cms reads from the Shopware CMS
• dev is the hot reload server for local development
• init is the way to go to start a project
• languages fetches locales from Shopware CMS
• override quickly override components
• plugins gathers assets
• snippets fetches the text snippets from Shopware CMS
10. What's in the box
Shopware 6 Client
• Javascript SDK for the Store API
• Can be used standalone, no composables dependency
• Endpoints.ts provides mapping
• Services are collections of methods around a specific domain
• Use apiService.invoke.get/post/put/… for custom APIs
11. What's in the box
Composables
• Provides interfaces for the Shopware 6 Client
• Composables provide business logic to the template
• These should be used in everyday development
• Backwards Compatible between versions
12. What's in the box
Default Theme
• Components, Layouts, Pages
• CMS contains elements we recognize from Shopware CMS
• cmsMap.json connects the vuejs component with the
Shopware CMS element
• Reuse where possible
• Great source for examples
13. Your local Project
Setup Shopware Backend
1. Install Shopware 6.3 (latest) with sample data
2. $ cd custom/plugin && git clone https://github.com/elkmod/SwagShopwarePwa
3. $ bin/console plugin:refresh && bin/console plugin:install --activate SwagShopwarePwa
4. $ bin/console dal:refresh:index
15. Your local Project
UPDATE `sales_channel_domain` SET `url` = 'http://192.168.1.105:3000/'
WHERE `sales_channel_domain`.`id` = CAST(0x8e2582ea9f7d4fb0ac76cf9dde71b3f3 AS BINARY);
16. Your local Project
Setup Shopware PWA
1. $ yarn add @shopware-pwa/cli
2. $ node_modules/.bin/shopware-pwa init
3. $ yarn dev
20. Building a plugin
• https://fakestoreapi.com/products
• Personalized greeting
• VS code as IDE
• Vetur installed (https://marketplace.visualstudio.com/items?itemName=octref.vetur)
• Vue.js devtools (for Chrome)
21. Building a plugin
• custom plugins go in sw-plugins
• or src/Resources/app/pwa in your Shopware plugin
• config.json tells ShopwarePWA about the plugin
34. https://fakestoreapi.com/products
[
{
"id": 1,
"title": "Fjallraven - Foldsack No. 1 Backpack, Fits 15
Laptops",
"price": 109.95,
"description": "Your perfect pack for everyday use and walks
in the forest. Stash your laptop (up to 15 inches) in the
padded sleeve, your everyday",
"category": "men clothing",
"image":
"https://fakestoreapi.com/img/81fPKd-2AYL._AC_SL1500_.jpg"
}
}