Skip to content

Instantly share code, notes, and snippets.

@steffen-wirth
Last active February 19, 2024 14:48
Show Gist options
  • Save steffen-wirth/d44b7a47587e1631f88a61e92b0a26fa to your computer and use it in GitHub Desktop.
Save steffen-wirth/d44b7a47587e1631f88a61e92b0a26fa to your computer and use it in GitHub Desktop.
# Theme Guide
https://developer.shopware.com/docs/guides/plugins/themes
# start theme hot-proxy (live reload)
./psh.phar storefront:hot-proxy
#### working with production template
1. install npm dependencies `cd vendor/shopware/storefront/Resources/app/storefront
; npm install;`
2. start watch process - frontend `cd /app; . bin/watch-storefront.sh;`
# TWIG templates
Als Grundlage für die Erweiterung des Frontend-Themes dienen die Dateien im Verzeichnis
(https://docs.shopware.com/de/shopware-6-de/tutorials-und-faq/aenderungen-am-template-vornehmen)
- /vendor/shopware/storefront/Resources/views/storefront
### easy extend twig templates using block name
- copy block name from html comments
- bin/console frosh:extend:template Theme name
- paste in block name and the block with parent() is created in your theme
# shopware-cli
- download tar from https://github.com/FriendsOfShopware/shopware-cli/releases/
- unpack in shopware root folder
# see twig template paths
with https://github.com/FriendsOfShopware/FroshDevelopmentHelper
- download zip file https://github.com/FriendsOfShopware/FroshDevelopmentHelper
- add to custom/plugin folder
- use ./shopware-cli extension prepare ./custom/plugins/FroshDevelopmentHelper
- its availabel in backend plugin manager now
# use snippet value for icons
{% set icon1 = 'footer.teaser.col1.icon'|trans %}
{% sw_include "@Storefront/storefront/utilities/icon.html.twig" with { 'name': icon1, 'size': 'xl'} %}
# Install production repo
### clone latest
git clone https://github.com/shopware/production src;
cd src;
composer install;
bin/console system:setup;
### create database with a basic setup (admin user and storefront sales channel)
bin/console system:install --create-database --basic-setup
#### de as default language
bin/console system:install --create-database --shop-locale=de-DE --shop-currency=EUR --basic-setup
!!! do not forget to switch en snippet set in storefront!!!
#### create admin user by cli
bin/console user:create --admin --email=john@doe.com --firstName="John" --lastName="Doe" --password=shopware --no-interaction admin
### optimize bin/build-storefront.sh
_disable chromium download 140mb_
export NPM_PACKAGE_CONFIG_PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
# DEBUG - XDEBUG
set path in Php Storm Config for /app and /app/public
# RESSOURCES
## PLUGINS
### configuration options
#### input types
<table><tbody><tr><td><strong>Type</strong></td><td><strong>Displayed item</strong></td><td><strong>Additional settings</strong></td></tr><tr><td>bool</td><td>On/off switch</td><td></td></tr><tr><td>checkbox</td><td>Checkbox</td><td></td></tr><tr><td>colorpicker</td><td>Color selector</td><td></td></tr><tr><td>date</td><td>Date selector</td><td></td></tr><tr><td>datetime</td><td>Date and time selector</td><td></td></tr><tr><td>float</td><td>One-line input for decimals</td><td></td></tr><tr><td>int</td><td>One-line input for integers</td><td></td></tr><tr><td>multi-select</td><td>Multi-select input</td><td>options, placeholder</td></tr><tr><td>password</td><td>One-line input for password</td><td>placeholder</td></tr><tr><td>single-select</td><td>Single-select input</td><td>options, placeholder</td></tr><tr><td>text</td><td>One-line text input</td><td>copyable, placeholder</td></tr><tr><td>textarea</td><td>Multi-line text input</td><td>copyable, placeholder</td></tr><tr><td>time</td><td>Time selector</td><td></td></tr><tr><td>url</td><td>One-line input for URL</td><td>copyable, placeholder</td></tr></tbody></table>
## Passing variables from a storefront controller to a Twig template
https://shopwarian.com/how-to-get-the-data-from-php-to-the-twig-template/
## add custom module for admin
https://webkul.com/blog/add-new-module-to-administration-in-shopware-6-how-to-add-custom-module-in-shopware-6/
#Migration
Problem bei Php 8.1 und PDO Konfig
https://stackoverflow.com/questions/73169064/swag-migration-run-exception-in-logs-while-migrating-from-shopware5-to-shopware6
## Infos zu Media Path Erstellung
https://stackoverflow.com/questions/72897964/shopware-6-media-file-path-from-database-mysql
```
SELECT
concat(
'public/media/',
REGEXP_REPLACE(left(md5(lower(hex(id))), 6), '(..)', '$1/'),
IFNULL(concat(FLOOR(UNIX_TIMESTAMP(uploaded_at)), '/'), ''),
file_name, '.', file_extension
) as path
FROM media
WHERE file_name='242178_0569-1';
```
# Upgrade 6.4 to 6.5
* deactivate all plugins
* deactivate Theme
```
bin/console system:update:prepare;
composer update;
# Führe die Datenbank Migration mit folgendem Befehl aus:
bin/console system:update:finish;
#
```
## Use Rector & frosh rector
https://github.com/FriendsOfShopware/shopware-rector
vendor/bin/rector process --config vendor/frosh/shopware-rector/config/shopware-6.5.0.php --autoload-file="/app/vendor/autoload.php" pathtoplugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment