Skip to content

Instantly share code, notes, and snippets.

View drobinson's full-sized avatar

David Robinson drobinson

View GitHub Profile
@drobinson
drobinson / install_xdebug_2-2-1.sh
Last active December 14, 2015 19:29
Install xdebug 2.2.1 (which allows for breakpoints to be set in symlinked files)
wget http://xdebug.org/files/xdebug-2.2.1.tgz
tar -xzvf xdebug-2.2.1.tgz
cd xdebug-2.2.1
phpize
./configure --enable-xdebug
sudo make
sudo make install
sudo service apache2 restart
@drobinson
drobinson / getModuleDir.php
Created March 12, 2013 18:22
Get path to a module component, good for getting the path to a controller when rewriting
Mage::getModuleDir(‘controllers’, ‘Packagename_Modulename’);
@drobinson
drobinson / salesrulebugfix.diff
Created May 14, 2013 21:38
Fixes salesrule times_used data update bug introduced in Magento CE 1.8 and EE 1.13 Salesrules with zero sum discount amounts (such as salesrules created for free shipping) will not have their times_used data updated.
Index: app/code/core/Mage/SalesRule/Model/Observer.php
===================================================================
--- app/code/core/Mage/SalesRule/Model/Observer.php (revision 146067)
+++ app/code/core/Mage/SalesRule/Model/Observer.php (working copy)
@@ -90,7 +90,6 @@
$customerId = $order->getCustomerId();
// use each rule (and apply to customer, if applicable)
- if ($order->getDiscountAmount() != 0) {
foreach ($ruleIds as $ruleId) {
@drobinson
drobinson / xdebug_settings.ini
Last active June 23, 2020 19:34
Xdebug settings for debugging using remote hosts and how to debug cli php scripts
zend_extension= /usr/lib/php/20170718/xdebug.so
[xdebug]
; This is the default, but just to be sure...
xdebug.remote_port = 9000
; Make sure vmhost is set in /etc/hosts as the ip address of your host machine
; from your virtual machine (set in virtual box as the host-only adapter ip)
@drobinson
drobinson / git_rm_untracked.sh
Created August 13, 2013 18:40
Remove all untracked changes from the current directory - good for package-based installs that have a lot of untracked changes (that you don't need for what you're working on) for some reason or another.
$ git clean -fdn
# -f force (because Obi-Wan says so)
# -d also removes directories
# -n dry run (ALWAYS do this first)
# You can also specify a path, but to be safe I always just cd to where I want to destroy changes
@drobinson
drobinson / rm_svn_tracking.sh
Created September 6, 2013 16:53
Recursively remove all .svn directories under the current directory
rm -rf `find . -type d -name .svn`
@drobinson
drobinson / product_list_block_fix.diff
Last active December 23, 2015 20:19
Fixes problem with loading a product list block while there is a "product" entity set on the registry
Index: app/code/core/Mage/Catalog/Block/Product/List.php
===================================================================
--- app/code/core/Mage/Catalog/Block/Product/List.php
+++ app/code/core/Mage/Catalog/Block/Product/List.php
@@ -71,7 +71,7 @@
// if the product is associated with any category
if ($categories->count()) {
// show products from this category
- $this->setCategoryId(current($categories->getIterator()));
+ $this->setCategoryId(current($categories->getIterator())->getId());
@drobinson
drobinson / form_key_checks.txt
Created December 11, 2013 16:38
List (and command that generated it) of places that form key validation has been added in 1.13.1
Controllers that have added form key validation:
$ git grep --files-with-matches "this->_validateFormKey())" <core_sources_update_commit_hash>
<core_sources_update_commit_hash>:app/code/core/Enterprise/Checkout/controllers/CartController.php
<core_sources_update_commit_hash>:app/code/core/Enterprise/GiftRegistry/controllers/IndexController.php
<core_sources_update_commit_hash>:app/code/core/Enterprise/GiftRegistry/controllers/ViewController.php
<core_sources_update_commit_hash>:app/code/core/Enterprise/Reward/controllers/CustomerController.php
<core_sources_update_commit_hash>:app/code/core/Enterprise/Wishlist/controllers/SearchController.php
<core_sources_update_commit_hash>:app/code/core/Mage/Catalog/controllers/Product/CompareController.php
<core_sources_update_commit_hash>:app/code/core/Mage/Checkout/controllers/CartController.php
#!/bin/bash
if [ ! -d $1/var ] ; then echo "Invalid directory $1/var"; exit 1; fi
SHMFOLDERS=( "full_page_cache" "cache" "session" )
for i in "${SHMFOLDERS[@]}" ; do
if [ ! -d $1/var/$i ] ; then echo "Invalid directory $1/var/$i"; exit 1; fi
if [ -d /dev/shm/$i ] ; then echo "Directory /dev/shm/$i already exists"; exit 1; fi
mv $1/var/$i /dev/shm/$i
ln -s /dev/shm/$i $1/var/$i
@drobinson
drobinson / install_xdebug.sh
Last active June 23, 2020 20:15
Installing and configuring xdebug on unibox
sudo pecl install xdebug
sudo wget -O /etc/php/7.2/mods-available/xdebug.ini https://gist.githubusercontent.com/drobinson/5979612/raw/73636ae1bb4e4864f4d7f816d8e83f496c47e52c/xdebug_settings.ini
sudo ln -s /etc/php/7.2/mods-available/xdebug.ini /etc/php/7.2/apache2/conf.d/25-xdebug.ini
sudo service apache2 restart