Skip to content

Instantly share code, notes, and snippets.

View sudhanshu-bajaj's full-sized avatar

Sudhanshu Bajaj sudhanshu-bajaj

View GitHub Profile
@sudhanshu-bajaj
sudhanshu-bajaj / reset-customer.sql
Created April 3, 2021 07:01
Magento 2: How to delete all customers data?
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `amazon_customer`;
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
TRUNCATE TABLE `customer_address_entity_decimal`;
TRUNCATE TABLE `customer_address_entity_int`;
TRUNCATE TABLE `customer_address_entity_text`;
TRUNCATE TABLE `customer_address_entity_varchar`;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
@sudhanshu-bajaj
sudhanshu-bajaj / reset-products-and-categories.sql
Last active April 3, 2021 07:11
Magento 2 : Truncate Products & Categories MySql
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
@sudhanshu-bajaj
sudhanshu-bajaj / backup-cli.sh
Last active April 4, 2021 11:20
Magento 2 : How to Backup Db, Media, Code command line
#If the Magento backup functionality does not start or displays the following message, you need to enable the feature prior to backing up.
# - Backup functionality is disabled.
# - Backup functionality is currently disabled. Please use other means for backups.
$ php bin/magento config:set system/backup/functionality_enabled 1
$ php bin/magento setup:backup --code
#Enabling maintenance mode
#Code backup is starting...
#Code backup filename: 1617533283_filesystem_code.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
#Code backup path: /Users/sudhanshubajaj/Projects/development/m23-ee-latest/var/backups/1617533283_filesystem_code.tgz
#[SUCCESS]: Code backup completed successfully.