Skip to content

Instantly share code, notes, and snippets.

View davidalexander's full-sized avatar

David Alexander davidalexander

View GitHub Profile
@davidalexander
davidalexander / gist:6937862
Created October 11, 2013 16:30
Magento - Report for count and revenue of promotions
SELECT
sr.`name` as rule_name,
count(*) as total_orders,
SUM(sfo.`total_paid`) as revenue,
sr.`rule_id`,
sfo.`applied_rule_ids`
FROM
`sales_flat_order` sfo,
`salesrule` sr
WHERE
@davidalexander
davidalexander / rsync_magento_media.sh
Last active January 29, 2020 10:01
rsync the media directory from live site to local site. Useful when you need imagery which is (correctly) ignored by version control.
rsync \
--verbose \
--progress \
--stats \
--compress \
--rsh=/usr/bin/ssh \
--recursive \
--times \
--perms \
--links \
@davidalexander
davidalexander / index.php
Last active October 4, 2015 22:48
Magento developer subdomains
/**
* Set developer mode and display_errors based on subdomain
*/
$staging_subdomains = array(
's1',
's2',
's3',
's4',
's5',
'mac',
@davidalexander
davidalexander / index.php
Created March 15, 2012 21:21
Thoughts on best way to test subdomain
<?php
/**
* how best to turn on errors for staging subdomains
*
* as this is in the index.php, performance is important,
* although technically the page will be cached
*/
// 1. preg_match
if (preg_match('/^s1\.|^s2\.|^s3\.|^s4\.|^s5\.|^mac\.|^local\.|^mac-upgrade\./', $_SERVER['HTTP_HOST'])) {
@davidalexander
davidalexander / .htaccess
Created July 16, 2011 21:15
Magento fix for IE9 issues
### IE users need a little help (Magento+IE9=bad times) ###
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=EmulateIE8,chrome=1" env=ie
</IfModule>
</IfModule>
<IfModule mod_headers.c>
# Because X-UA-Compatible isn't sent to non-IE (to save header bytes),
# We need to inform proxies that content changes based on UA
@davidalexander
davidalexander / gist:1086773
Created July 16, 2011 20:47
.htaccess Environments
# http://thenerdary.net/articles/entry/htaccess-environments
RewriteEngine On
RewriteBase /
### SET UP ENVIORNMENTS ###
# Default to master
RewriteRule .* - [E=ENVIRONMENT:master]
@davidalexander
davidalexander / gist:1086732
Created July 16, 2011 20:26
jQuery Dismiss Lightbox with ESC
// Bind a custom event to the lightbox that can be triggered when it needs to be dismissed:
$('.lightbox').bind('dismiss', function() {
// code to dismiss lightbox
});
// Then just trigger that event when escape it pressed:
$(document).bind('keyup', function(e) {
if(e.keyCode == 27) {
@davidalexander
davidalexander / iframe.js
Created July 16, 2011 16:43
Add a class to the html tag if the page is being loaded in an iframe
if (window.location !== window.parent.location) {
document.documentElement.className += ' iframe';
}
@davidalexander
davidalexander / gist:1086455
Last active September 7, 2023 07:42
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

@davidalexander
davidalexander / index.html
Created July 16, 2011 15:33
Simple jQuery Tabs
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="tabs.js"></script>
</head>
<body>
<div class="tab-container">