Skip to content

Instantly share code, notes, and snippets.

View vanWittlaer's full-sized avatar

Benny Poensgen vanWittlaer

View GitHub Profile
@vanWittlaer
vanWittlaer / gist:92ca82c19d39ea38089af2a5459599db
Created July 16, 2018 09:21
Using the addAttribute method for the ListProduct class
class ListProductService implements ListProductServiceInterface
{
/**
* @var ListProductServiceInterface
*/
private $service;
/** @var Container */
private $container;
@vanWittlaer
vanWittlaer / gist:39d738877f0e6aa275ebff2925b1227b
Created August 27, 2018 14:37
cURL a website like Google bot
curl -v -L --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" https://vanwittlaer.de
@vanWittlaer
vanWittlaer / truncate_articles.sql
Created May 22, 2019 09:43
Shopware 5.5 - reset article and related data
SET foreign_key_checks = 0;
TRUNCATE shopware.s_addon_premiums;
TRUNCATE shopware.s_articles;
TRUNCATE shopware.s_articles_also_bought_ro;
TRUNCATE shopware.s_articles_attributes;
TRUNCATE shopware.s_articles_avoid_customergroups;
TRUNCATE shopware.s_articles_categories;
TRUNCATE shopware.s_articles_categories_ro;
TRUNCATE shopware.s_articles_categories_seo;
TRUNCATE shopware.s_articles_details;
@vanWittlaer
vanWittlaer / jquery.presetFacet.js
Last active October 22, 2019 14:53
To preset a filter facet (here: 'immediate delivery') in Shopware5
;(function ($, window, document, undefined) {
'use strict';
window.onload = function () {
document.getElementById('delivery').checked = true;
$('#delivery').triggerHandler('change');
};
})(jQuery, window, document, undefined);
@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.
@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: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 / 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 / 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
# 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