Skip to content

Instantly share code, notes, and snippets.

Peter Jaap Blaakmeer peterjaap

Block or report user

Report or block peterjaap

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@peterjaap
peterjaap / 1_product_queries.sql
Created Sep 16, 2019 — forked from itris/1_product_queries.sql
Magento 2 - Remove duplicate store view-specific product and category data
View 1_product_queries.sql
/*
* IMPORTANT: The queries below are written for Magento Enterprise. If you're going to run them on Magento Community, you need
* to replace all instances of ".row_id" with ".entity_id". See this for context: http://magento.stackexchange.com/questions/139740/magento-2-schema-changes-for-ee-catalog-staging
*
* When importing products in Magento 2, if you specify store view codes in the store_view_code column, product data will be set at
* both the global scope as well as the specific store view scope. This is not ideal because now you have duplicate
* data at two different scopes that shouldn't actually be duplicated. The scripts below clean up this data by finding
* data set at specific store view scopes and if it's an exact match to the data set at the global store view, then it
* deletes the data set at the specific store view scope.
*
@peterjaap
peterjaap / lockComposerJsonToPatchReleases.php
Last active Jul 1, 2019
Lock your composer.json package versions to the latest installed version and prepend a tilde to lock to patch releases only
View lockComposerJsonToPatchReleases.php
<?php
// One-line all the things !1!1!!
// wget https://gist.githubusercontent.com/peterjaap/f89df7260aab48b1a1700bffd2779a64/raw/lockComposerJsonToPatchReleases.php && php lockComposerJsonToPatchReleases.php && rm lockComposerJsonToPatchReleases.php
$composerLockData = json_decode(file_get_contents('composer.lock'), true);
$composerJsonData = json_decode(file_get_contents('composer.json'), true);
$excludedPackages = ['magento/product-community-edition', 'composer/composer'];
@peterjaap
peterjaap / convertDeityTranslationJsonToOneSkyCSV.php
Created Jun 18, 2019
Convert Deity translation JSON file to OneSky CSV format. Usage; php convertTranslationJson.php client/node_modules/@deity/falcon-i18n/i18n/en/translations.json
View convertDeityTranslationJsonToOneSkyCSV.php
<?php
$input = json_decode(file_get_contents($argv[1]));
$output = [];
foreach ($input as $aKey => $aValue) {
if (is_object($aValue) || is_array($aValue)) {
foreach ($aValue as $bKey => $bValue) {
if (is_object($bValue) || is_array($bValue)) {
foreach($bValue as $cKey => $cValue) {
@peterjaap
peterjaap / app-etc-config-diff.sh
Created Apr 1, 2019
Oneliner to quickly diff a re-ordered Magento 2 config.php file
View app-etc-config-diff.sh
git diff app/etc/config.php > temp; diff -wB <(sort temp) <(git show HEAD:temp | sort -); rm temp
@peterjaap
peterjaap / PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-module-catalog.patch
Last active Mar 27, 2019
Magento 2.2 patch for PRODSECBUG-2198 in composer.patches.json format for magento/module-catalog. See for magento/framework https://gist.github.com/peterjaap/433a07a08962ea8955e64b39c84cc4e3
View PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-module-catalog.patch
diff --git a/Model/Product/ProductFrontendAction/Synchronizer.php b/Model/Product/ProductFrontendAction/Synchronizer.php
index 7a1926c..331c667 100644
--- a/Model/Product/ProductFrontendAction/Synchronizer.php
+++ b/Model/Product/ProductFrontendAction/Synchronizer.php
@@ -138,7 +138,9 @@ class Synchronizer
$productIds = [];
foreach ($actions as $action) {
- $productIds[] = $action['product_id'];
+ if (isset($action['product_id']) && is_int($action['product_id'])) {
@peterjaap
peterjaap / PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch
Last active Mar 29, 2019
Magento 2.2 patch for PRODSECBUG-2198 in composer.patches.json format for magento/framework. See for magento/module-catalog https://gist.github.com/peterjaap/d7eaceb0e28e76cb92426a9defed0d9a
View PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch
diff --git a/DB/Adapter/Pdo/Mysql.php b/DB/Adapter/Pdo/Mysql.php
index 1449d6d..38085a3 100644
--- a/DB/Adapter/Pdo/Mysql.php
+++ b/DB/Adapter/Pdo/Mysql.php
@@ -2904,7 +2904,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
if (isset($condition['to'])) {
$query .= empty($query) ? '' : ' AND ';
$to = $this->_prepareSqlDateCondition($condition, 'to');
- $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName);
+ $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName);
@peterjaap
peterjaap / .gitlab-ci.yaml
Last active Mar 5, 2019
Generic Gitlab CI file to build and push a Docker container to the private registry using kaniko (no Docker in Docker privileged mode needed)
View .gitlab-ci.yaml
image: docker:latest
stages:
- build
build:
stage: build
only:
- master
image:
@peterjaap
peterjaap / gatsby-node.js
Last active Nov 21, 2018
Magento 2.3 GraphQL all products query for Gatsby
View gatsby-node.js
const _ = require('lodash')
const { GraphQLClient } = require('graphql-request')
const path = require('path')
const crypto = require('crypto')
const baseUrl = 'https://www.yourmagento2shop.com/'
const { createRemoteFileNode } = require(`gatsby-source-filesystem`)
// Query Magento 2.3
@peterjaap
peterjaap / magento-2-3-occurrence-analysis.csv
Last active Oct 4, 2018
Occurrence analysis on backward incompatible classes/interfaces of current state of Magento 2.3 upgrade on non-core code of one of our 2.2.6 shops. Based on https://devdocs.magento.com/guides/v2.3/release-notes/backward-incompatible-changes/open-source.html
View magento-2-3-occurrence-analysis.csv
Class/Interface Occurrences
Magento\Catalog\Model\Product 1777
Magento\Store\Model\Store 1658
Magento\Sales\Model\Order 1267
Magento\Store\Model\StoreManagerInterface 1166
Magento\Quote\Model\Quote 803
Magento\Framework\Filesystem 702
Magento\Catalog\Model\ResourceModel\Product 559
Magento\Framework\App\ResourceConnection 534
Magento\Config\Model\Config 509
@peterjaap
peterjaap / customer-sensitive-columns.sql
Created Jul 10, 2018
Quick query to find possible customer-data sensitive columns
View customer-sensitive-columns.sql
SELECT table_schema, table_Name, column_name FROM information_schema.columns
WHERE table_schema = 'yourdatabasename' AND
(
column_name LIKE '%address%'
OR column_name LIKE '%email%'
OR column_name LIKE '%customer_%'
)
AND column_name NOT LIKE 'customer_%id%'
AND column_name NOT LIKE 'email_%id%'
ORDER BY table_name,ordinal_position
You can’t perform that action at this time.