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 / 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 http://elgentos.nl/
// @version 1.0.0
// @description Github Magento 2 - create definition for composer patches
// @author Peter Jaap Blaakmeer <peterjaap@elgentos.nl>
// @match https://github.com/*/*/pull/**
// @match https://github.com/*/*/commit/**
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @grant GM_addStyle
@peterjaap
peterjaap / Observer.php
Created Jun 2, 2015
Fixed Orchid_CouponFix_Model_Observer for Magento 1.7+
View Observer.php
<?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
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
ORDER BY sku DESC)
@peterjaap
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|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|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
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
<?php
/**
* @param $attributeCode
* @param $newOptionValues
* @internal param $attributeData
*/
public function addSwatchValuesToSwatchAttribute($attributeCode, $newOptionValues)
{
$this->eavConfig->clear();
@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 / fixtags.php
Last active Aug 2, 2019
Replace PHP short open tags with long form open tags - PHP script version. Slightly adapted from https://github.com/danorton/php_replace_short_tags -- usage; find . -type f -iname "*.phtml" | xargs php -d short_open_tag=On fixtags.php --overwrite
View fixtags.php
#!php-cli
<?php
/**
* php_replace_short_tags
* Copyright © 2010 Weirdmasters, Austin, Texas
*
* License:
* CC-BY-SA v3.0
* http://creativecommons.org/licenses/by-sa/3.0/
*
@peterjaap
peterjaap / magento-testing-scenarios.md
Last active Jul 25, 2019
Magento testing scenarios
View magento-testing-scenarios.md

Magento testing scenarios

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

SHIP IT

Frontend

General

  • Activate all logs on the server (PHP, MySQL, Magento, mail, etc)
  • Check meta tags in HTML
@peterjaap
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
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'];
You can’t perform that action at this time.