Skip to content

Instantly share code, notes, and snippets.

View markshust's full-sized avatar
🤓
Working on educational & training material for Magento 2

Mark Shust markshust

🤓
Working on educational & training material for Magento 2
View GitHub Profile
@rhoerr
rhoerr / create_aggregated_eav_views.sql
Last active May 20, 2025 14:21
MySQL views to aggregate Magento 2 EAV data -- requires MySQL 5.7+ or equivalent
/**
* Create aggregated SQL views for default EAV entity types in Magento:
* - dev_category
* - dev_product
* - dev_customer
* - dev_address
*
* Each view has the primary entity table, plus associated EAV values (eav_int, eav_text, etc).
* This is meant as a development tool to quickly see or select scoped data for a given entity.
* Do not use these for any runtime code, and be careful about how many rows you fetch at once.
services:
app:
ports: !reset []
labels:
- "traefik.enable=true"
- "traefik.http.routers.magento-loc.tls=true"
- "traefik.http.routers.magento-loc.rule=Host(`magento.loc`)"
- "traefik.http.services.magento-loc.loadbalancer.server.port=8443"
- "traefik.http.services.magento-loc.loadbalancer.server.scheme=https"
networks:
@adamzero1
adamzero1 / README.md
Last active June 29, 2024 11:41
Get more descriptive error when DOM validation fails in Magento

Get a more debugable error message when DOM validation fails in Magento.

Original Error Message

1 exception(s):
Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'arguments': This element is not expected.
Line: 1471
/**
* Run in the console to inline all code block styles before
* copy + pasting into ConvertKit in HTML mode
*/
const CSS_PROPERTIES = [
'background-color',
'font-size',
'color',
];
@zepgram
zepgram / AbstractPdf.php
Created June 17, 2022 13:43
PDF size reduction for Magento 2
<?php
declare(strict_types=1);
namespace MyNamespace\Sales\Model\Order\Pdf;
use Magento\Sales\Model\Order\Pdf\AbstractPdf as MagentoAbstractPdf;
/**
* Drastically reduce size of PDF by changing fonts
@levelsio
levelsio / git_graph.php
Last active June 5, 2023 03:49
GitHub style graph in PHP + CSS
<style>
.git-graph {
text-align: left;
line-height: 1;
}
.git-graph-row {
clear: both;
text-align: left;
}
.git-graph-cell {
@hostep
hostep / composer-v2-support-older-magento2-versions.md
Last active February 4, 2025 10:24
Add composer v2 support to older Magento2 versions

Add composer v2 support to older Magento2 versions

Magento 2.3.7 and 2.4.2 ship with composer v2 support out of the box but as far as I can see the only thing that needs to happen is to use some more modern versions of certain composer plugins which are used by certain dependencies of Magento.

This means we should be able to add composer v2 support to older Magento2 versions as well if we get a bit creative.

See below for diffs of the composer.json files you can apply to your projects, be sure to keep a mental note of these things, they will need to maintained by yourself in case newer versions of these modules are released. And if one day you update to Magento 2.3.7 or 2.4.2 or higher, you can remove these changes again.

⚠️ Disclaimer: use these tricks at your own risk!

// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@magenx
magenx / carding.sh
Last active December 30, 2024 09:56
#!/bin/bash
MAGE_BASE_URL="$1"
MAGE_SKU="$2"
PAYMENT_KEY="$3"
PAYMENT_METHOD="$4"
STORE_VIEW="$5"
CREDIT_CARD="$6"
CREDIT_CARD_CVC="$7"
@andyrbell
andyrbell / scanner.sh
Last active May 31, 2025 00:04
Make a pdf look scanned using ImageMagick
# use ImageMagick convert
# the order is important. the density argument applies to input.pdf and resize and rotate to output.pdf
convert -density 90 input.pdf -rotate 0.5 -attenuate 0.2 +noise Multiplicative -colorspace Gray output.pdf