Skip to content

Instantly share code, notes, and snippets.

View Tjitse-E's full-sized avatar

Tjitse Tjitse-E

View GitHub Profile
<?php
namespace Mynamespace\RegenerateUrls\Console\Command;
use Magento\Framework\Exception\AlreadyExistsException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@Tjitse-E
Tjitse-E / remove_files_from_git.sh
Created August 21, 2017 15:55
Git remove files from history
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@Tjitse-E
Tjitse-E / settings.sql
Last active October 14, 2020 07:53
Prepare Magento 2 production database for usage with Valet Plus
-- Update all dev settings to false
UPDATE `core_config_data`
SET `value` = 0
WHERE (`path` REGEXP '^dev.*')
AND `value` = 1;
-- Update Sphinx when using Mirasvit Sphinx Search
UPDATE `core_config_data`
SET `value` = 'mysql2'
WHERE `value` = 'sphinx';
@Tjitse-E
Tjitse-E / find_cacheable_false.sh
Created August 28, 2019 11:54 — forked from jeroenvermeulen/find_cacheable_false.sh
Magento2: Find cacheable="false" in layout XML
#### by MageHost.pro ####
# execute in Magento 2 root:
find vendor app -regextype 'egrep' -type f -regex '.*/layout/.*\.xml' -not -regex '.*(vendor/magento/|/checkout_|/catalogsearch_result_|/dotmailer|/msp).*' | xargs grep --color -n -e 'cacheable="false"'
@Tjitse-E
Tjitse-E / DataPatchCmsBlocks.php
Created December 10, 2019 15:03
Create new CMS block Magento 2
<?php declare(strict_types=1);
namespace Vendic\SampleModule\Setup\Patch\Data;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Cms\Api\Data\BlockInterfaceFactory;
use Magento\Cms\Api\BlockRepositoryInterface;
class CreateDesktopMenuCmsBlocks implements DataPatchInterface
{
@Tjitse-E
Tjitse-E / anonymize.yml
Last active January 4, 2021 11:43
Github action recipe to backup a remote DB via n98-magerun2, anonymize with Masquerade and push the file to DigitalOcean Spaces (S3)
name: Fetch DB, anonymize and upload to S3
env:
MASQUERADE_DOWNLOAD_URL: 'https://github.com/elgentos/masquerade/releases/latest/download/masquerade.phar'
DO_SPACES_HOST: 'ams3.digitaloceanspaces.com'
ANONYMIZED_DB_NAME: 'db_anonymized.sql.gz'
MYQSL_HOST: '127.0.0.1'
MYSQL_PWD: 'root'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} # source server host
REMOTE_USER: ${{ secrets.REMOTE_USER }} # source server use
REMOTE_PORT: ${{ secrets.REMOTE_PORT }} # source server port
@Tjitse-E
Tjitse-E / phpunit_9_fixes.sh
Last active March 17, 2021 12:53
PHPunit 6 to 9, change 'protected function setup' to 'public function setup'
# Requires gsed (Mac OSX) or sed (Linux)
targets=$(grep -HRl "function setUp()" app)
for i in ${targets}; do
echo $i
/usr/local/bin/gsed -i 's/[a-zA-Z]\+ function setUp().*/protected function setUp(): void/' "$i"
done
@Tjitse-E
Tjitse-E / mysql_update.sh
Last active June 7, 2021 14:13
Mysql 8 update via brew (Magento 2)
# Update all dependencies via brew
brew update
brew upgrade
# validate php
php -v
# When problems re-occur fix them first. I had to run 'brew reinstall icu4c' because my icu4c dependency was missing.
# Remove mysql 5.7
brew services stop mysql@5.7
@Tjitse-E
Tjitse-E / magento_generate_store_mapping.sh
Last active June 15, 2021 12:51
Generate a Magento 2 store mapping
#!/usr/bin/env bash
# Generates the Magento multistore config based on the base url list that's provided by n98-magerun2
# You can place the output in pub/index.php
IFS='
'
magerun2=$(which n98-magerun2)
[ -z "$magerun2" ] && echo "Cannot find magerun2, exiting." && exit 1
echo "switch (\$_SERVER['HTTP_HOST']) {"
@Tjitse-E
Tjitse-E / valet-install.md
Created April 14, 2022 09:20
Valet+ install on M1 Mac's.

Install Valet+

Install brew

First we need to install Brew, the dependency for the Mac:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install PHP

MacOS Monterney comes without PHP. Valet+ uses a special version of PHP that you can install like this: