Skip to content

Instantly share code, notes, and snippets.

View mhhansen's full-sized avatar

Martin Hansen mhhansen

  • Buenos Aires, Argentina
View GitHub Profile
@mhhansen
mhhansen / magento-2-anonymize-db.sql
Last active April 30, 2021 07:04
Magento 2 - anonymize db
-- Admin emails
UPDATE admin_user AS tb SET tb.email = CONCAT('customer', tb.user_id, '@mailinator.com');
-- Customers
UPDATE customer_entity AS tb SET tb.email = CONCAT('customer', tb.entity_id, '@mailinator.com');
-- Customers Grid
UPDATE customer_grid_flat AS tb SET tb.email = CONCAT('customer', tb.entity_id, '@mailinator.com');
-- Newsletter Subscribers
@mhhansen
mhhansen / magento-1-anonymize-db.sql
Last active November 12, 2019 21:14
Magento 1 - Anonymize db
# Customers
UPDATE customer_entity AS tb SET tb.email = CONCAT('customer', tb.entity_id, '@mailinator.com');
# Newsletter Subscribers
UPDATE newsletter_subscriber AS tb SET tb.subscriber_email = REPLACE (tb.subscriber_email,(SUBSTRING_INDEX(SUBSTR(tb.subscriber_email, INSTR(tb.subscriber_email, '@') + 1),'.',5)), 'mailinator.com');
# Sales Flat Orders
UPDATE sales_flat_order AS tb SET tb.customer_email = REPLACE (tb.customer_email,(SUBSTRING_INDEX(SUBSTR(tb.customer_email, INSTR(tb.customer_email, '@') + 1),'.',5)), 'mailinator.com');
# Sales Flat Orders Address
@mhhansen
mhhansen / deployVeniaSampleData.sh
Last active February 25, 2019 16:28
pwa-studio PR#329
#!/usr/bin/env bash
add_composer_repository () {
name=$1
type=$2
url=$3
echo "adding composer repository ${url}"
${composer} config ${composerParams} repositories.${name} ${type} ${url}
}
add_venia_sample_data_repository () {
@mhhansen
mhhansen / pwa-studio-setup-magento-230-alpha.txt
Last active October 19, 2019 08:10
Magento PWA Studio setup with 2.3.0-alpha
################################################################
# NODE: 8.11.2
# NPM: 5.6.0 (I prob should upgrade this one)
# MySQL: 5.7
# PHP: 7.1
################################################################
################################################################
################################
### DOWNLOAD AND PREPARE MAGENTO TO INSTALL
# assuming you are in /<YOUR_PROJECT_FOLDER>/
@mhhansen
mhhansen / validations.js
Last active July 7, 2017 18:41
JS validation - codigo postal, nro documento, telefono.
/**
* US phone format:
* - 1 followed by a digit different from 0, followed by 9 digits (18884622592)
* - a digit different from 0, followed by 9 digits (8884622592)
*/
function main(target){
return /(^[1]{0,1}[1-9]{1}[0-9]{9}$)/.test(target);
};
/**
@mhhansen
mhhansen / commands.txt
Last active June 28, 2017 13:18
Magento 2 pinned commands
# Magento 2 install common tasks
# alias
nano ~/.bash_profile
alias mage='php bin/magento'
# git ignore filemode changes
git config core.filemode false
# other git global configs
@mhhansen
mhhansen / emulator
Last active August 29, 2015 14:07
Magento Environment Emulator
$storeId = '0';
$appEmulation = Mage::getSingleton('core/app_emulation');
// start emulation
$envInfo = $appEmulation->startEnvironmentEmulation($storeId);
/**
* do your stuff in that Store
*/
@mhhansen
mhhansen / magento-reindex-process
Last active August 29, 2015 14:04
Magento : Index process from console
# extracted from http://www.atwix.com/magento/process-magento-indexes-from-command-line/
# - - - - - - - - - - - - - - - - - - - - - - - - - - -
# INDEXES NAMES LIST
# catalog_product_attribute
# catalog_product_price
# catalog_url
# catalog_product_flat
# catalog_category_flat
# catalog_category_product
@mhhansen
mhhansen / Invoice.php
Last active August 29, 2015 14:02
MageMonkey Mandrill + WebShopApps PDF Invoicing : Attachments
/**
* Webshopapps_Invoicing
* File: app/code/community/Webshopapps/Invoicing/Sales/Model/Order/Invoice.php
*
* Change addAttachment() function at the end of the file, to use this content
*/
public function addAttachment($mailTemplate,$pdf, $filename) {
$file=$pdf->render();
$mailTemplate->getMail()->createAttachment(
@mhhansen
mhhansen / disable-magento-compilation
Last active August 29, 2015 14:02
Magento : Disable Compilation
# Clear cache
rm -Rf var/cache/*
# Disable Magento Compilation
php -f shell/compiler.php -- disable
php -f shell/compiler.php -- clear
# Remove all compiled files
rm -Rf includes/src/*