Skip to content

Instantly share code, notes, and snippets.

View erikhansen's full-sized avatar

Erik Hansen erikhansen

View GitHub Profile
@erikhansen
erikhansen / gist:d80b54dca751d92a585fea84651fbac3
Created March 6, 2024 16:33
module-shipper-show-company-name-in-addresses-in-checkout.patch
Index:/src/view/frontend/web/template/shipping-address/address-renderer/default.html
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/view/frontend/web/template/shipping-address/address-renderer/default.html b/src/view/frontend/web/template/shipping-address/address-renderer/default.html
--- a/src/view/frontend/web/template/shipping-address/address-renderer/default.html
+++ b/src/view/frontend/web/template/shipping-address/address-renderer/default.html (date 1709742374536)
@@ -11,6 +11,11 @@
<div class="shipping-address-item" css="'selected-item' : isSelected() , 'not-selected-item':!isSelected()">
@erikhansen
erikhansen / README.md
Last active December 6, 2023 17:15
Troubleshoot long-running PHP script in Magento 2 on Warden

For future reference:

I just had to troubleshoot a script that ran so long that it eventually died without any relevant errors ([pid 6048:tid 139809649469184] (104)Connection reset by peer: [client 184.4.89.70:0] FastCGI: comm with server "/var/run/a49982b9-remi-safe-php81.fcgi" aborted: read failed, referer was getting written to the Apache error logs).

Thankfully I was able to reproduce the issue locally. Here are the steps I took in Warden to troubleshoot:

In pub/index.php I added this line: set_time_limit(15); above the $bootstrap->run($app);

cd <PATH TO MAGENTO 2 DIRECTORY>
@erikhansen
erikhansen / _README.md
Last active July 28, 2023 02:08
MacOS Automator Script to export list of on-premise Jira issues to PDF

Instructions

This document covers how to export Jira tickets to PDF from the on-premise version of Jira. For the cloud version of Jira, you can write a script to download Word versions of each issue (e.g., https://krakencommerce.atlassian.net/si/jira.issueviews:issue-word/DMC-95/DMC-95.doc) and you don't need this approach.

  1. Prepare a text file containing all urls of the Jira issues you want to export. For example:
https://krakencommerce.atlassian.net/browse/DMC-1
https://krakencommerce.atlassian.net/browse/DMC-2
@erikhansen
erikhansen / warmer-cron.sh
Created August 4, 2020 16:54 — forked from davidalger/warmer-cron.sh
Script to crawl and warm the cache two levels deep on Magento demo Pods via CronJob spec
#!/bin/bash
set -euo pipefail
FRONT_URL="${FRONT_URL:-https://app.exampleproject.test/}"
echo "==> [$(date +%H:%M:%S)] waiting on readiness"
ELAPSED_SECONDS=0
while : ; do
ELAPSED_SECONDS=$(echo ${ELAPSED_SECONDS}+2 | bc)
RESPONSE_CODE=$(curl -sI "${FRONT_URL}" 2>/dev/null | head -n1 | awk '{print $2}')
@erikhansen
erikhansen / README.md
Last active July 15, 2020 20:14
Issue with using flock with Magento's cron

Overview

This applies to Magento 2.3+.

If you have your crontab configured to run the bin/magento cron:run command using flock, you should either:

  • Remove flock, since it's technically not necessary as of Magento 2.3.2
  • Pass the -o command to flock, as this will prevent the indefinitely running bin/magento queue:consumers:start processes spawned by bin/magento cron:run from holding a lock when they shouldn't be.

Before:

@erikhansen
erikhansen / README.md
Last active August 15, 2023 09:21
Running Warden on Windows with WSL 1 & 2

Running Warden on Windows with WSL 2

See this Github comment thread for any issues or additional context for getting Warden running on Windows with WSL 2.

The instructions below cover how to install Warden on Windows, using WSL 2.

  1. Install Ubuntu 20 LTS in WSL 2
    1. To access the shell/terminal inside of Ubuntu WSL, open the Ubuntu 20.04 program that will have been installed in the step above (If you want to be able to copy/paste, see here. Going forward, this article assumes you will run all commands inside of the Ubuntu terminal
  2. Install Docker Desktop (these instructions were tested using Docker 4.9.0 on June 13th, 2022)
  3. Install homebrew `
# clear the entire cache
varnishadm "ban req.url ~ /"
# monitor varnish log with multiple patterns
varnishlog | grep 'eqURL\|Age:\|VCL_call\|TTL\|Expires:\|Cache-Control:'
# Use a query with varnishlog to watch requests from a specific IP
varnishlog -q 'ReqHeader:X-User-IP eq "1.2.3.4" or BereqHeader:X-User-IP eq "1.2.3.4"'
# Monitor PURGE requests hitting Varnish
diff --git a/Declaration/Schema/Comparator.php b/Declaration/Schema/Comparator.php
--- a/Setup/Declaration/Schema/Comparator.php
+++ b/Setup/Declaration/Schema/Comparator.php
@@ -24,7 +24,38 @@
*/
public function compare(ElementInterface $first, ElementInterface $second)
{
+ // Code below pulled from https://github.com/magento/magento2/issues/19597#issuecomment-463611130
+ //Ugly patch (MariaDB compatibility)
+ $firstParams = $first->getDiffSensitiveParams();
@erikhansen
erikhansen / README.md
Last active February 4, 2021 16:05
Magento 2 performance comparison after disabling unnecessary third-party extensions

Overview

I ran some tests to determine the speed impact of removing unnecessary third-party extensions, per this article: https://www.integer-net.com/make-magento-2-small-again/ The TL;DR is that pages loaded about 10% faster (with full_page and block_html disabled) with the unnecessary extensions removed.

Extensions I removed:

"replace": {
        "magento/module-dhl": "*",
        "magento/module-fedex": "*",
@erikhansen
erikhansen / settings.sh
Created December 19, 2019 22:14
Default M2 Production Settings
#!/bin/bash
TODO