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 / github-magento2-composer-patch.js
Last active Nov 21, 2019
Tampermonkey script to create copy/pastable composer patch definition for vaimo/composer-patches from Magento PR's and commits
View github-magento2-composer-patch.js
// ==UserScript==
// @name Create copy/pastable composer patch definition for vaimo/composer-patches
// @namespace
// @version 1.0.0
// @description Github Magento 2 - create definition for composer patches
// @author Peter Jaap Blaakmeer <>
// @match*/*/pull/**
// @match*/*/commit/**
// @require
// @grant GM_addStyle
peterjaap / Observer.php
Created Jun 2, 2015
Fixed Orchid_CouponFix_Model_Observer for Magento 1.7+
View Observer.php
class Orchid_CouponFix_Model_Observer
public function cancel($observer)
$resource = Mage::getModel('core/resource');
$db = $resource->getConnection('core_write');
$event = $observer->getEvent();
$order = $event->getPayment()->getOrder();
if ($order->canCancel()) {
peterjaap / attachToWebsite.sql
Created Sep 24, 2014
Magento SQL query to attach products that are not added to a website to the default website (id 1)
View attachToWebsite.sql
INSERT INTO catalog_product_website
(product_id, website_id)
(SELECT catalog_product_entity.entity_id, '1'
FROM catalog_product_entity LEFT JOIN catalog_product_website ON catalog_product_entity.entity_id = catalog_product_website.product_id
GROUP BY catalog_product_entity.entity_id
HAVING COUNT(catalog_product_website.product_id) = 0
peterjaap / server.blacklist
Last active Sep 19, 2019
Bad bot blacklist nginx config file (used on Hypernodes for Magento - place in /data/web/nginx/server.blacklist)
View server.blacklist
# Main list
if ($http_user_agent ~* (360Spider||Abonti|AcoonBot|Acunetix|adbeat_bot||adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|DISCo|discobot|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearch|ExpertSearchSpider|Express\ WebPictures|extract|ExtractorPro|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|genieo|Genieo|GetRight|GetWeb\!|GigablastOpenSource|Go\-Ahead\-Got\-It|Go\!Zilla|GozaikBot|grab|GrabNet|Grafula|GrapeshotCrawler|GT\:\:
peterjaap / swatch_attribute_options.php
Created Nov 28, 2017
Helper functions for product import in Magento 2 to create swatch attribute options
View swatch_attribute_options.php
* @param $attributeCode
* @param $newOptionValues
* @internal param $attributeData
public function addSwatchValuesToSwatchAttribute($attributeCode, $newOptionValues)
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:
* 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 / fixtags.php
Last active Aug 2, 2019
Replace PHP short open tags with long form open tags - PHP script version. Slightly adapted from -- usage; find . -type f -iname "*.phtml" | xargs php -d short_open_tag=On fixtags.php --overwrite
View fixtags.php
* php_replace_short_tags
* Copyright © 2010 Weirdmasters, Austin, Texas
* License:
* CC-BY-SA v3.0
peterjaap /
Last active Jul 25, 2019
Magento testing scenarios

Magento testing scenarios

For use after an upgrade to verify the correct working of Magento




  • Activate all logs on the server (PHP, MySQL, Magento, mail, etc)
  • Check meta tags in HTML
peterjaap / deleteUnconvertedQuotes.sql
Created Sep 19, 2014
Delete unconverted and inactive quotes from Magento
View deleteUnconvertedQuotes.sql
DELETE FROM sales_flat_quote WHERE (updated_at < DATE_SUB(NOW(),INTERVAL 60 DAY) || is_active = 0)
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
// One-line all the things !1!1!!
// wget && 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'];
You can’t perform that action at this time.