This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- STEP 1: Set @database, @old_prefix and @new_prefix | |
-- STEP 2: Execute the query | |
-- STEP 3: Copy the string that was genereated by the query | |
-- STEP 4: Run the generated query to rename all tables | |
-- STEP 5: Use you Party Gun to make it rain! | |
SET SESSION group_concat_max_len = 999999999; | |
SET @database = "databasename"; | |
SET @old_prefix = "ma2_"; | |
SET @new_prefix = ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## NOTE: when finding file by time, use one of the following flags: | |
# ctime : the time a file was changed, in hours. On most systems this timestamp cannot be altered by any user, so it is fairly reliable | |
# atime : the time a file was last accessed, in hours. This is also set by the system. | |
# mtime : the modified time of a file, in hours. This can be set by any user. So if you are looking for mailcious files, never use this flag. | |
# cmin : same as mtime, but in minutes. | |
# amin : same as atime, but in minutes. | |
# mmin : same as mtime, but in minutes. | |
# Find all files in current directory changed more than 8 hours ago (480 minutes) | |
find $PWD -mindepth 1 -type f -cmin +480 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Magento 2 Deployment Script | |
# Author: Joost van Veen | |
usage="$(basename "$0") [-h] source-directory destination-directory folders-to-sync files-to-sync | |
Rsync folders and files from one folder to another | |
where: | |
-h show this help text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- DEFAULT MAGENTO: REQUIRE FIRSTNAME, LASTNAME, EMAIL, TELEPHONE | |
UPDATE `ma2_eav_attribute` SET is_required = 1 WHERE attribute_code = 'firstname'; | |
UPDATE `ma2_eav_attribute` SET is_required = 1 WHERE attribute_code = 'lastname'; | |
UPDATE `ma2_eav_attribute` SET is_required = 1 WHERE attribute_code = 'email'; | |
UPDATE `ma2_eav_attribute` SET is_required = 1 WHERE attribute_code = 'telephone'; | |
-- DO NOT REQUIRE FIRSTNAME, LASTNAME, EMAIL, TELEPHONE | |
UPDATE `ma2_eav_attribute` SET is_required = 0 WHERE attribute_code = 'firstname'; | |
UPDATE `ma2_eav_attribute` SET is_required = 0 WHERE attribute_code = 'lastname'; | |
UPDATE `ma2_eav_attribute` SET is_required = 0 WHERE attribute_code = 'email'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET FOREIGN_KEY_CHECKS = 0; | |
-- TRUNCATE ORDERS | |
TRUNCATE TABLE `PREFIX_gift_message`; | |
TRUNCATE TABLE `PREFIX_quote`; | |
TRUNCATE TABLE `PREFIX_quote_address`; | |
TRUNCATE TABLE `PREFIX_quote_address_item`; | |
TRUNCATE TABLE `PREFIX_quote_id_mask`; | |
TRUNCATE TABLE `PREFIX_quote_item`; | |
TRUNCATE TABLE `PREFIX_quote_item_option`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET FOREIGN_KEY_CHECKS = 0; | |
-- truncate products | |
TRUNCATE TABLE `PREFIX_cataloginventory_stock_item`; | |
TRUNCATE TABLE `PREFIX_cataloginventory_stock_status`; | |
TRUNCATE TABLE `PREFIX_cataloginventory_stock_status_idx`; | |
TRUNCATE TABLE `PREFIX_cataloginventory_stock_status_tmp`; | |
TRUNCATE TABLE `PREFIX_catalog_category_product`; | |
TRUNCATE TABLE `PREFIX_catalog_category_product_index`; | |
TRUNCATE TABLE `PREFIX_catalog_category_product_index_tmp`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET FOREIGN_KEY_CHECKS = 0; | |
-- TRUNCATE CUSTOMERS | |
TRUNCATE TABLE `PREFIX_customer_address_entity`; | |
TRUNCATE TABLE `PREFIX_customer_address_entity_datetime`; | |
TRUNCATE TABLE `PREFIX_customer_address_entity_decimal`; | |
TRUNCATE TABLE `PREFIX_customer_address_entity_int`; | |
TRUNCATE TABLE `PREFIX_customer_address_entity_text`; | |
TRUNCATE TABLE `PREFIX_customer_address_entity_varchar`; | |
TRUNCATE TABLE `PREFIX_customer_entity`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($http_user_agent ~ "PHPCrawl|bGenius|SemrushBot|Yandex|YandexBot|MegaIndex|spbot|BLEXBot|ltx71|Daum|SpotBot|DotBot|seoscanners|domaincrawler|CCBot|SeznamBot|SMTBot") { | |
return 403; | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Delete all orders from Magento 2 | |
SET FOREIGN_KEY_CHECKS=0; | |
# Clean order history | |
TRUNCATE TABLE PREFIX_sales_bestsellers_aggregated_daily; | |
TRUNCATE TABLE PREFIX_sales_bestsellers_aggregated_monthly; | |
TRUNCATE TABLE PREFIX_sales_bestsellers_aggregated_yearly; | |
# Clean order infos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Export all customers from Magento - names & email addresses | |
select ce.entity_id, concat(cevf.value, ' ', cevl.value) fullname, ce.email | |
from customer_entity ce | |
inner join customer_entity_varchar cevf | |
on ce.entity_id = cevf.entity_id | |
inner join eav_attribute eaf | |
on eaf.attribute_id = cevf.attribute_id | |
inner join customer_entity_varchar cevl | |
on ce.entity_id = cevl.entity_id |