Skip to content

Instantly share code, notes, and snippets.

Magento 2 Training Workbook

This repository contains a list of practice tasks to build skill important to be a good php engineer. Magento 2 just happens to be a tool that we are using here to understand large codebases. Principles learned while deep diving into Magento are very similar to principles used in other frameworks.

Before you jump into Magento 2 codebase, it's important to understand configurations available in Magento. Install opensource version on your local machine.Explore at

@Knase
Knase / git-revert-sha-commit
Created March 17, 2024 21:18 — forked from mgibowski/git-revert-sha-commit
[git] revert to a commit by sha hash
# found at:
# http://stackoverflow.com/questions/1895059/git-revert-to-a-commit-by-sha-hash
# reset the index to the desired tree
git reset --hard 56e05fced
# move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
@Knase
Knase / pkglist.php
Created August 24, 2023 11:42 — forked from alankent/pkglist.php
Connect to Magento 2 Composer repo and list packages you can access
<?php
/**
* Return the path of the auth.json file.
*/
function findAuthJson() {
// Windows sets HOMEDRIVE and HOMEPATH, but cygwin sets HOME.
if (!isset($_SERVER["HOME"]) && isset($_SERVER["HOMEDRIVE"])) {
@Knase
Knase / mount.md
Created August 14, 2023 21:18
Mac OS Mount RW NTFS

Write to NTFS support MacOS

1. Get the partition UUID

Connect the external drive to MacOS. It should mount read-only. Start "System Information", clic on Hardware -> Storage, select your drive in the list and copy its UUID.

Another way to get the UUID is to use the diskutil CLI tool:

~$ diskutil list 
~$ distutil info diskXsY
@Knase
Knase / Magento2-remove-orders-customers
Created June 2, 2023 00:13 — forked from carlowens/Magento2-remove-orders-customers
Magento 2 remove test data of orders and customers
SET FOREIGN_KEY_CHECKS = 0;
#clear orders
TRUNCATE TABLE `gift_message`;
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
@Knase
Knase / gist:dd0e03aa1ff50379fb4f09cff6683664
Created January 11, 2023 17:29
Patch a Package in Vendor
composer require cweagans/composer-patches symplify/vendor-patches --dev
cp vendor/nette/di/src/DI/Extensions/InjectExtension.php vendor/nette/di/src/DI/Extensions/InjectExtension.php.old
#add changes in main file
vendor/bin/vendor-patches generate
#check file /patches/nette-di-di-extensions-injectextension.php.patch
#check composer.json
composer install
@Knase
Knase / README.md
Last active March 6, 2023 22:00 — forked from molotovbliss/README.md
Synced via Snip

Speed up warden for faster importing of large sql dumps.

  1. Add the innodb options to the warden/environments/magento2.base.yml docker-compose YML file.
  2. Restart warden environment warden env down && warden sync stop && warden env up -d && warden sync start
  3. Import the .sql file with warden db import.
  4. Remove options & restart warden enviornment once import completed.

Why these settings

  • innodb_buffer_pool_size : Will cache frequently read data
@Knase
Knase / README.md
Created October 30, 2022 16:46 — forked from molotovbliss/README.md
Speed up warden for faster importing of large sql dumps.

Speed up warden for faster importing of large sql dumps.

  1. Add the innodb options to the warden/environments/magento2.base.yml docker-compose YML file.
  2. Restart warden environment warden env down && warden sync stop && warden env up -d && warden sync start
  3. Import the .sql file with warden db import.
  4. Remove options & restart warden enviornment once import completed.

Why these settings

  • innodb_buffer_pool_size : Will cache frequently read data
sudo lsof -i -P -n | grep LISTEN
sudo netstat -tulpn | grep LISTEN
sudo ss -tulpn | grep LISTEN
sudo lsof -i:22 ## see a specific port such as 22 ##
sudo nmap -sTU -O IP-address-Here
@Knase
Knase / run.sql
Created October 10, 2022 23:31 — forked from DavaGordon/run.sql
Magento 2 - Delete All Test Orders
SET FOREIGN_KEY_CHECKS=0;
# Clean order history
TRUNCATE TABLE `sales_bestsellers_aggregated_daily`;
TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`;
TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`;
# Clean order infos
TRUNCATE TABLE `sales_creditmemo`;
TRUNCATE TABLE `sales_creditmemo_comment`;