Skip to content

Instantly share code, notes, and snippets.

View peterjaap's full-sized avatar

Peter Jaap Blaakmeer peterjaap

  • elgentos ecommerce solutions / Blaakmeer Webdevelopment
  • Groningen, the Netherlands
View GitHub Profile
@peterjaap
peterjaap / m2_cl.sql
Last active April 25, 2024 08:10
Magento 2 changelog table structure - note; this has mage_ prefix.
-- MySQL dump 10.13 Distrib 5.7.19-17, for debian-linux-gnu (x86_64)
--
-- ------------------------------------------------------
-- Server version 5.7.19-17
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
@peterjaap
peterjaap / varnish6.vcl
Last active March 13, 2024 21:57
Updated Magento 2 Varnish 6 VCL, in cooperation with Varnish Software
# A number of these changes come form the following PR's; , combines changes in https://github.com/magento/magento2/pull/29360, https://github.com/magento/magento2/pull/28944 and https://github.com/magento/magento2/pull/28894, https://github.com/magento/magento2/pull/35228, https://github.com/magento/magento2/pull/36524, https://github.com/magento/magento2/pull/34323
# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
vcl 4.1;
import std;
# The minimal Varnish version is 6.0
# For SSL offloading, pass the following header in your proxy server or load balancer: '/* {{ ssl_offloaded_header }} */: https'
backend default {
.host = "/* {{ host }} */";
@peterjaap
peterjaap / cleanImages.php
Last active February 14, 2024 14:17
Script to clean up the images tables in a Magento installation. Removes references to non-existing images, removes duplicate images, sets correct default image and deletes orphaned images from the filesystem.
<?php
/*
* This script deletes duplicate images and imagerows from the database of which the images are not present in the filesystem.
* It also removes images that are exact copies of another image for the same product.
* And lastly, it looks for images that are on the filesystem but not in the database (orphaned images).
*
* This script can most likely be optimized but since it'll probably only be run a few times, I can't be bothered.
*
* Place scripts in a folder named 'scripts' (or similar) in the Magento root.
@peterjaap
peterjaap / server.blacklist
Last active January 1, 2024 13:39
Bad bot blacklist nginx config file (used on Hypernodes for Magento - place in /data/web/nginx/server.blacklist)
# Main list
if ($http_user_agent ~* (360Spider|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|DISCo|discobot|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearch|ExpertSearchSpider|Express\ WebPictures|extract|ExtractorPro|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|genieo|Genieo|GetRight|GetWeb\!|GigablastOpenSource|Go\-Ahead\-Got\-It|Go\!Zilla|GozaikBot|grab|GrabNet|Grafula|GrapeshotCrawler|GT\:\:
@peterjaap
peterjaap / quick-magento-2-install.sh
Last active September 21, 2023 14:24
Quick Magento 2 install
#!/bin/bash
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
cd magento2
DB_NAME=dbnamehere php bin/magento setup:install --base-url=http://elgentos.magento2.localhost/ --db-host=db --db-name=${DB_NAME} --db-user=peterjaap --admin-firstname=PJ --admin-lastname=Blaakmeer --admin-email=peterjaap@elgentos.nl --admin-user=peterjaap --admin-password=peterjaap123 --language=en_US --currency=EUR --timezone=Europe/Amsterdam --use-rewrites=1 --backend-frontname=admin --amqp-host=rabbitmq --amqp-port=5672 --amqp-user=guest --amqp-password=guest --amqp-virtualhost="/" --search-engine=elasticsearch7 --elasticsearch-host=elasticsearch7 --elasticsearch-port=9200 --elasticsearch-enable-auth=0 --elasticsearch-index-prefix=magento2_${DB_NAME} --elasticsearch-timeout=15 --use-sample-data
php bin/magento deploy:mode:set developer
@peterjaap
peterjaap / lestifpc_manadev.patch
Created March 4, 2015 09:42
Fix Lesti_Fpc + Manadev SEO Layered Navigation
diff --git a/app/code/community/Lesti/Fpc/Helper/Data.php b/app/code/community/Lesti/Fpc/Helper/Data.php
index 94e9ea1..daec7e1 100644
--- a/app/code/community/Lesti/Fpc/Helper/Data.php
+++ b/app/code/community/Lesti/Fpc/Helper/Data.php
@@ -70,7 +70,13 @@ class Lesti_Fpc_Helper_Data extends Lesti_Fpc_Helper_Abstract
'port' => $request->getServer('SERVER_PORT'),
'full_action_name' => $this->getFullActionName());
$uriParams = $this->_getUriParams();
- foreach ($request->getParams() as $requestParam =>
+ $manadevParams = array();
@peterjaap
peterjaap / identify.php
Last active September 6, 2023 08:12
Identify used Magento 2 frontend extensions in a Luma install
<?php
// Run with the URL pointing to a require-config.js as the first argument;
// php identify.php http://magento2demo.firebearstudio.com/pub/static/frontend/Magento/luma/en_US/requirejs-config.js
$content = file_get_contents($argv[1]);
preg_match_all(
'/(?P<quote>\'|")(?P<extension>[[:alnum:]]+_[[:alnum:]]+)\/js\/.+?(?P=quote)/m',
$content,
$matches
@peterjaap
peterjaap / ACSD-51892_2.4.6.patch
Created July 11, 2023 07:28
Drop-in ACSD-51892 patch for 2.4.6 / 2.4.6-p1 in vaimo/composer-patches format
@package magento/framework
@level 4
@version >=103.0.6 <103.0.7
diff --git a/vendor/magento/framework/App/DeploymentConfig.php b/vendor/magento/framework/App/DeploymentConfig.php
index 6713baa3a1d..64f32d5516b 100644
--- a/vendor/magento/framework/App/DeploymentConfig.php
+++ b/vendor/magento/framework/App/DeploymentConfig.php
@@ -51,6 +51,16 @@ class DeploymentConfig
*/
@peterjaap
peterjaap / n8n.php
Created March 28, 2023 12:34
Deployer task n8n webhook to update PHP packages Airtable. Set the webhook URL to the env var N8N_WEBHOOK_PACKAGES
<?php
desc('Send the composer.lock file to our n8n endpoint to save package information in our overview');
task('update-packages-overview', function () {
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => getenv('N8N_WEBHOOK_PACKAGES'),
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => file_get_contents('composer.lock'),
@peterjaap
peterjaap / PHP_packages_composer_lock_Magento_projects.json
Last active March 30, 2023 09:31
N8N.io Workflow PHP packages composer.lock Magento projects
{
"name": "PHP packages composer.lock Magento projects",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "24577e32-bda2-48d3-9721-509294f9cc89",
"options": {}
},
"id": "525eb7eb-bdcb-4a47-a5a1-dc84d166c8a3",