Skip to content

Instantly share code, notes, and snippets.

@steffen-wirth
steffen-wirth / LayoutLoadBeforeObserver.php
Created May 14, 2021 14:21 — forked from 0-Sony/LayoutLoadBeforeObserver.php
Magento 2 : Add Body Class using an observer
<?php
/**
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Phuong LE <phuong.le@agence-soon.fr> <@>
* @copyright Copyright (c) 2017 Agence Soon (http://www.agence-soon.fr)
*/
namespace MyVendor\MyModule\Observer;
@steffen-wirth
steffen-wirth / CustomMail.php
Created May 14, 2021 14:21 — forked from 0-Sony/CustomMail.php
Magento 2 : Custom Send Email - (Tested on Magento 2.2.6)
<?php
/**
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @author Phuong LE <phuong.le@menincode.com>
* @copyright Copyright (c) 2020 Men In Code Ltd (https://www.menincode.com)
*/
namespace Namespace\MyModule\Model\SendMail;
use Magento\Framework\App\Area;
@steffen-wirth
steffen-wirth / create_attributes.php
Created May 14, 2020 07:45 — forked from nklatt/create_attributes.php
Programmatically add new product attribute with options to a Magento 2 store and add to Default attribute group
<?php
defined('STDIN') or die(_("Access Denied. CLI Only"));
// execute from the command line: php <path to magento root>/cli/create_attributes.php
require __DIR__.'/../app/bootstrap.php'; // assuming this file is in /cli under the root magento dir
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$installer = $bootstrap->getObjectManager()->create('Magento\Catalog\Setup\CategorySetup');
$objectManager = $bootstrap->getObjectManager();
@steffen-wirth
steffen-wirth / security.conf
Created March 24, 2020 11:08 — forked from ambroisemaupate/security.conf
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@steffen-wirth
steffen-wirth / AnyPage.vue
Created March 17, 2020 13:43 — forked from kingsloi/AnyPage.vue
Vue 2 - VueRouter - Simple Dynamic breadcrumbs + Microdata
export default {
beforeRouteEnter(route, redirect, next) {
next(vm => {
vm.$http.get(`${API.BASE}/${API.PAGE}/${route.name}`).then((response) => {
vm.page = response.data.page;
vm.eventHub.$emit('update-breadcrumb', [
{
title: 'Home',
@steffen-wirth
steffen-wirth / gulpfile.js
Created July 3, 2019 07:57 — forked from antwon/gulpfile.js
(Gulp 4) Basic gulpfile front-end starter kit
// ----- Gulp ----- //
// Compiles sass with sourcemaps, combines js, prefix-free styles, live reloads browser
// cd into your project and run 'gulp'
// compiles sass
// combines js
// prefix-free styles
// live reloads browser
var gulp = require('gulp'),
diff -rupN mage_org/app/code/core/Mage/Catalog/Model/Url.php src_shop/app/code/core/Mage/Catalog/Model/Url.php
--- mage_org/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:48:25.679009391 +0100
+++ src_shop/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:49:24.188005601 +0100
@@ -643,13 +643,24 @@ class Mage_Catalog_Model_Url
$this->_rewrite = $rewrite;
return $requestPath;
}
+
+ // avoid unnecessary creation of new url_keys for duplicate url keys
+ $noSuffixPath = substr($requestPath, 0, -(strlen($suffix)));
@steffen-wirth
steffen-wirth / OrderMod_Bootstrap.php
Created January 11, 2018 11:23 — forked from sthamann/OrderMod_Bootstrap.php
Advanced Example how to create 2 custom fields, fill them in order process, display them in backend order list as new columns and make them editable in order detail view
<?php
class Shopware_Plugins_Frontend_OrderMod_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
/**
* (non-PHPdoc)
* @see Shopware_Components_Plugin_Bootstrap::install()
*/
public function install()
{
@steffen-wirth
steffen-wirth / WindowsSetup.md
Created January 10, 2018 14:38 — forked from valeryan/WindowsSetup.md
Local WSL Setup

Windows Development Environment Setup

This document outlines the steps I take to setup my environment on windows using WSL. This requires being on the windows 10 Creative update or greater with Ubuntu 16 installed as WSL.

Windows Setup

  1. Install WSL
  2. Install Terminus and setup to use bash for windows.
  3. Install Acrylic DNS Proxy
  4. Download WSL Startup Scripts
  5. Install Xming (optional)
@steffen-wirth
steffen-wirth / persistent_c_mount_wsl.sh
Created December 16, 2017 18:34 — forked from sgtoj/persistent_c_mount_wsl.sh
Ubuntu for Windows: Mounting C: Drive to WSL's Root
# allow `mount` cmd without password
echo "$USER ALL=NOPASSWD: /bin/mount" | (sudo su -c 'EDITOR="tee -a" visudo')
# add the mount directive to `fstab`
sudo mkdir -p /c
sudo sh -c "echo '/mnt/c /c none bind' >> /etc/fstab"
# update to `.bashrc` to auto mount at login
echo "sudo mount -a" >> ~/.bashrc
# now reload it
source ~/.bashrc