Skip to content

Instantly share code, notes, and snippets.

View petemcw's full-sized avatar

Pete McWilliams petemcw

View GitHub Profile
@petemcw
petemcw / 2.2.10.patch
Created October 18, 2019 14:44
Template patch for Magento Open Source 2.2.10
--- vendor/magento/module-backup/view/adminhtml/templates/backup//list.phtml 2019-09-19 15:52:44.000000000 -0500
+++ vendor/magento/module-backup/view/adminhtml/templates/backup//list.phtml 2019-10-17 17:37:00.000000000 -0500
@@ -7,4 +7,4 @@
<?= $block->getChildHtml('grid') ?>
<?= $block->getGridHtml() ?>
<?= $block->getDialogsHtml() ?>
-<?php
+
--- vendor/magento/module-bundle/view/base/templates/product/price/selection/amount.phtml 2019-09-19 15:52:44.000000000 -0500
@petemcw
petemcw / gist:1169053
Created August 24, 2011 20:06 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@petemcw
petemcw / sphp.sh
Created November 19, 2018 20:59
Switch PHP versions script
#!/usr/bin/env bash
BREW_PREFIX=$(brew --prefix | sed 's#/#\\\/#g')
BREW_ARRAY=("5.6","7.0","7.1","7.2")
PHP_ARRAY=("php@5.6" "php@7.0" "php@7.1" "php@7.2")
PHP_INSTALLED_ARRAY=()
PHP_VERSION="php@$1"
PROFILE="/Users/prm/.zshrc"
# Has the user submitted a version required
@petemcw
petemcw / CustomerSessionCheck.php
Created July 13, 2018 15:03
Magento 2.x Is Customer Logged In?
<?php
namespace Petemcw;
use Magento\Customer\Model\Session;
class Customer
{
/**
* @var \Magento\Customer\Model\Session
@petemcw
petemcw / default.vcl
Created May 22, 2011 02:20
Lullabot's Custom Varnish VCL File
#
# Customized VCL file for serving up a Drupal site with multiple back-ends.
#
# For more information on this VCL, visit the Lullabot article:
# http://www.lullabot.com/articles/varnish-multiple-web-servers-drupal
#
# Define the internal network subnet.
# These are used below to allow internal access to certain files while not
# allowing access from the public internet.
@petemcw
petemcw / gist:a3292cb65851ecfc0e26
Created June 10, 2014 20:43
Quick cheat sheet for merging two separate repositories while retaining commit history.
#
# Basic process for merging two Git repositories while retaining commit history.
# - This seems to work pretty well for migrations to Pantheon
#
# Clone the repository that will be the final origin
git clone <repository_uri_1> <local_dir>
cd <local_dir>
# Add the second repository as a remote
@petemcw
petemcw / gist:1427528
Created December 3, 2011 16:41
Re-order Magento Categories Alphabetically
SET @position = 0;
SET @last_parent = 0;
SET @last_level = 0;
DROP TABLE IF EXISTS `cce_new_position`;
CREATE TEMPORARY TABLE `cce_new_position`
SELECT
`new`.`entity_id` AS `entity_id`,
`new`.`parent_id` AS `parent_id`,
@last_parent := CAST(`new`.`parent_id` AS UNSIGNED) AS `new_parent_id`,
`new`.`name` AS `name`,
@petemcw
petemcw / gist:2719758
Created May 17, 2012 15:53
Commands to clean a Ubuntu install for smaller Vagrant packages
# Remove items used for building, since they aren't needed anymore
apt-get clean
apt-get -y remove linux-headers-$(uname -r) build-essential
apt-get -y autoremove
# Zero out the free space to save space in the final image:
dd if=/dev/zero of=/EMPTY bs=1M
rm -f /EMPTY
# Removing leftover leases and persistent rules
@petemcw
petemcw / gist:1201928
Created September 7, 2011 22:04
MySQL user creation
GRANT USAGE ON *.* TO `user`@`localhost` IDENTIFIED BY 'password';
GRANT CREATE ROUTINE, CREATE VIEW, ALTER, SHOW VIEW, CREATE, ALTER ROUTINE, INSERT, SELECT, DELETE, UPDATE, DROP, LOCK TABLES, CREATE TEMPORARY TABLES, INDEX ON `database`.* TO `user`@`localhost` IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
@petemcw
petemcw / vhost.conf
Created August 31, 2011 14:33
Sample Apache vhost Configuration File
<VirtualHost *:80>
DocumentRoot "/path/to/web/files/"
ServerAdmin webmaster@localhost
ServerName localhost
#SetEnv MAGE_IS_DEVELOPER_MODE true
#SetEnv MAGE_RUN_CODE storecode
#SetEnv MAGE_RUN_TYPE website
<Directory "/path/to/web/files/">