Skip to content

Instantly share code, notes, and snippets.

@peterjaap
peterjaap / DB_CLEANUP_WITH_QUOTE_TABLE.php
Last active April 13, 2020 20:46
Updated Magento 2 cleanup script for sensitive data in wishlist_item_option, quote_item_option AND order_item_option (not in original script). Also added try/catch block for unserializable data. See for more info https://support.magento.com/hc/en-us/articles/360040209352 and https://magento.com/security/hot-fix-available-cve-2019-8118
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\Bootstrap;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Query\Generator;
use Magento\Framework\DB\Select\QueryModifierFactory;
@peterjaap
peterjaap / generate-magento-2-php-client.sh
Last active December 5, 2019 22:04
Generate PHP client with Swagger for Magento 2 including private endpoints (make sure you have the Swagger modules installed & enabled)
#!/bin/bash
SHOP_URL=https://yourshop.url
ADMIN_USERNAME=yourusername
ADMIN_PASSWORD=yourpassword
BEARER=$(curl -XPOST -H 'Content-Type: application/json' ${SHOP_URL}/index.php/rest/V1/integration/admin/token -d '{ "username": "${ADMIN_USERNAME}", "password": "${ADMIN_PASSWORD}" }')
curl -XGET -H "Authorization: Bearer ${BEARER}" ${SHOP_URL}/rest/default/schema?services=all | tee swagger.json
docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate -i /local/swagger.json -l php -o /local/
@borriglione
borriglione / gist:32ece6a306f31c45cc81a66931891d2e
Created July 2, 2018 08:01
Magento Database Anonymization after Live-Database Import
#!/bin/bash
echo "*** This script is anonymizing a DB-dump of the LIVE-DB in the DEMO-Environment ***"
HOST=`grep host ../app/etc/local.xml | sed 's/ *<host>\(.*\)<\/host>/\1/' | sed 's/<!\[CDATA\[//' | sed 's/\]\]>//'`
USER=`grep username ../app/etc/local.xml | sed 's/ *<username>\(.*\)<\/username>/\1/' | sed 's/<!\[CDATA\[//' | sed 's/\]\]>//'`
PASS=`grep password ../app/etc/local.xml | sed 's/ *<password>\(.*\)<\/password>/\1/' | sed 's/<!\[CDATA\[//' | sed 's/\]\]>//'`
NAME=`grep dbname ../app/etc/local.xml | sed 's/ *<dbname>\(.*\)<\/dbname>/\1/' | sed 's/<!\[CDATA\[//' | sed 's/\]\]>//'`
echo ""
@timneutkens
timneutkens / README.md
Last active April 15, 2021 12:10
Magento2 | Execute data-mage-init and x-magento-init in dynamic content (ajax request)

Execute data-mage-init and x-magento-init in dynamic content (ajax response)

Trigger .trigger('contentUpdated') on the element where dynamic content is injected.

$.ajax({
    url: 'https://www.example.com',
    method: 'POST',
    data: {
 id: '1'
@wsakaren
wsakaren / install_magento2_with_db
Last active December 15, 2017 17:22
Install script for magento2 with database, assumes you are running from www.localhost.com/20
#!/bin/bash
# Sets up a database with a magento2 installation. This assumes you are running from under your httpdocs/<release> location and have www.localhost.com in your /etc/hosts file
# To run type : install_magento2 <dirname> <password> <release>
# password is used for the datbase user and the magento admin password
if [ $# -eq 0 ]; then
echo "No arguments supplied"
echo "Usage: `basename $0` <dirname> <password> <release>"
echo "e.g install_magento2.sh mage2 password 21"
exit 1
@avoelkl
avoelkl / gist:3ed0fdc5d7fd171ea591
Last active August 29, 2015 14:20
All the times & dates & places for #mhlej15 & #mm15de
@schmengler
schmengler / SSE_FormFiller Bookmarklets.md
Last active June 27, 2019 11:47
Bookmarklets: Fill Magento forms with data powered by Faker.js

These bookmarklets allow you to use the scripts of SSE_FormFiller in any Magento installation without having to install the extension.

  1. Load FormFiller:

     javascript:(function%20(){document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).src='https://cdnjs.cloudflare.com/ajax/libs/Faker/0.7.2/MinFaker.js';document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).src='https://rawgit.com/schmengler/FormFiller/master/js/sse/formfiller.js';}());
    
  2. Fill billing form:

     javascript:formFiller.fill(billingForm.form)
    
@wsakaren
wsakaren / magento2_install
Last active August 29, 2015 14:11
Installing Magento2 - The quick way
So we all hate reading docs. Here is the quick setup for installing Magento2. If you want the long route - http://devdocs.magento.com/
I'm assuming you have composer, PHP 5.4+ and MySQL5.6+. If you have MAMP installed time to go sort that as it wont work (MAMP is on MySQL5.5.x).
1. Install Composer - curl -sS https://getcomposer.org/installer | php
2. mv composer.phar /usr/local/bin/composer (might need to sudo)
3. Goto base httpdocs directory
4. git clone git@github.com:magento/magento2.git
5. Set permissions (like you do in Magento 1.x)
6. cd magento2
@magentogirl
magentogirl / gist:e8dc6aa7c74d021f85cc
Last active January 8, 2019 11:32
config.xml to disable Magento Logging
<?xml version="1.0"?>
<config>
<frontend>
<events>
<!--disable logs-->
<controller_action_predispatch>
<observers><log><type>disabled</type></log></observers>
</controller_action_predispatch>
<controller_action_postdispatch>
<observers><log><type>disabled</type></log></observers>
@bastianccm
bastianccm / composer.json
Created September 7, 2013 13:45
php composer.phar install
{
"require": {
"connect20/mage_all_latest": "1.7.*"
},
"repositories": [
{
"type": "composer",
"url": "http://packages.firegento.com/"
}
],