Skip to content

Instantly share code, notes, and snippets.

View vanWittlaer's full-sized avatar

Benny Poensgen vanWittlaer

View GitHub Profile
@vanWittlaer
vanWittlaer / sample-api-with-query.txt
Created February 28, 2024 09:57
Append query to Shopware API requests
Shopware admin API requests can be enriched with a query.
For example, to retrieve only snippets for a particular snippet set, use this query:
{{HOST}}/api/snippet?query[0][query][type]=equals&query[0][query][field]=setId&query[0][query][value]=685f610ee07544feb28b6a5abf38cf7c
@vanWittlaer
vanWittlaer / install.sh
Last active June 12, 2024 09:58
Shopware 6 - ddev Quick Install
#!/usr/bin/env bash
# What it does:
# - Creates a local Shopware installation using the Symfony Flex template for local development of client projects
# - Prerequisites: ddev installed on your machine, see https://ddev.com/get-started/
#
# How to use:
# - create a project folder
# - copy this file into the project folder
# - chmod +x install.sh
# Being stuck by PhpStorm indexing on all CPUs? On Ubuntu, you can limit PhpStorm to using just say 4 of your CPUs by amending
# the Exec directive with 'taskset -a -c 0,1,2,3' in its desktop file (usually located in /usr/share/applications)
[Desktop Entry]
Version=1.0
Type=Application
Name=PhpStorm
Icon=/opt/PhpStorm-212.5080.71/bin/phpstorm.svg
Exec="taskset -a -c 0,1,2,3 /opt/PhpStorm-212.5080.71/bin/phpstorm.sh" %f
Comment=Lightning-smart PHP IDE
@vanWittlaer
vanWittlaer / dbdump5.sh
Last active July 15, 2021 11:40
A simple bash script to dump a Shopware 5 database using settings from config.php
#!/usr/bin/env bash
#
# usage: ./dbdump5.sh <shopware project root dir> <target file for dump>
#
# note this script requires PHP and gzip
#
root=${1:-/var/www/shopware/shopware}
target=${2:-test.sql.gz}
config=${3:-php}
#
# this is a files/folder exclude list to be used with tar when archiving a Shopware 6 project folder
# use like 'tar -cvzf --exclude-from=tar-exclude.txt my_archive.tar.gz shopware'
# you may have to replace shopware with the name of your project folder, and remove all comment lines
shopware/.env
shopware/config/jwt/*.pem
shopware/var/cache/dev_*
shopware/var/cache/prod_*
shopware/var/log/*.log
# optional:
# shopware/files
@vanWittlaer
vanWittlaer / dbdump.sh
Last active August 4, 2021 14:57
A simple bash script to mysqldump a Shopware 6 database using .env settings
#!/usr/bin/env bash
#
# usage: ./dbdump.sh <shopware project root dir> <target file for dump>
#
# note 1) this script requires PHP and gzip
# note 2) the --skip-triggers option breaks the blue-green-deployment however is usefull for re-importing on another server
#
# Trouble with generated columns?
# - See this: https://dba.stackexchange.com/questions/240882/how-to-take-mysqldump-with-generated-column
# - Though I recommend to find a compatible mysqldump client
@vanWittlaer
vanWittlaer / sw6-config-multi-select
Created February 23, 2021 16:05
Shopware 6 config multi-select
Define in config.xml:
<component name="sw-entity-multi-id-select">
<name>b2bCustomerGroupIds</name>
<entity>customer_group</entity>
<label>Choose multiple customer groups as B2B groups</label>
<label lang="de-DE">Wählen Sie die für B2B vorgesehenen Kundengruppen.</label>
</component>
Use in twig:
@vanWittlaer
vanWittlaer / gist:ec0ef48f571357b84b19796a20dcd42f
Created April 3, 2020 12:51
Enable php-fpm with fast-fcgi and HTTP2 on ubuntu 18.04/apache2
# run as sudo
apt update
apt install php-fpm
a2enmod proxy_fcgi
a2enconf php7.2-fpm
a2dismod php7.2
a2dismod mpm_prefork
a2enmod mpm_event
a2enmod http2
service apache2 restart
@vanWittlaer
vanWittlaer / gist:89dd99c94e3b4077e60b8b5f2a2c080f
Created February 4, 2020 16:31
Controlling sitemap.xml output via config.php (since SW 5.5)
'sitemap' => [
'excluded_urls' => [
[
// Possible resources:
// - product (\Shopware\Models\Article\Article::class)
// - campaign (\Shopware\Models\Emotion\Emotion::class)
// - manufacturer (\Shopware\Models\Article\Supplier::class)
// - blog (\Shopware\Models\Blog\Blog::class)
// - category (\Shopware\Models\Category\Category::class)
// - static (\Shopware\Models\Site\Site::class)
@vanWittlaer
vanWittlaer / gist:9415b199012908ab38f6cb16e911d17e
Created January 20, 2020 15:10
Gitlab runner running out of space (in /var/lib/docker/overlay2)
SSH to the runner and execute 'docker system prune --all --volumes --force' - this will wipe any unused docker stuff.