Skip to content

Instantly share code, notes, and snippets.

View pkdavies's full-sized avatar

Peter Davies pkdavies

View GitHub Profile
@pkdavies
pkdavies / gist:1080324
Created July 13, 2011 13:50
Apache optimisation for Magento
FileETag none
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
ExpiresByType text/html "access"
ExpiresByType text/xml "access plus 60 minutes"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
@pkdavies
pkdavies / download.php
Last active September 27, 2015 01:17
Correct cross-browser force CSV
<?php
$filename = "my-csv-file-".date("Y-m-d").".csv";
ob_start( ini_get('zlib.output_compression')? 'ob_gzhandler' : '' );
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: public");
header("Cache-Control: max-age=0");
@pkdavies
pkdavies / apcfrag.php
Created June 8, 2012 12:31
APC cache fragmentation only value for monitoring service
<?php
ini_set('display_errors',1);
ini_set('error_reporting', E_ALL);
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// default display mode
//$display_mode='formatted';
@pkdavies
pkdavies / gist:3060960
Created July 6, 2012 15:40
PHP based high resolution image combiner
<?php
$oldpath = "./in/";
$newpath = "./out/";
$dir_iterator = new RecursiveDirectoryIterator($oldpath);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
$files_all = $files_copied = $files_replaced = 0;
@pkdavies
pkdavies / newsletter-import.php
Created July 11, 2012 10:41
Magento newsletter mass import script
<?php
ini_set('memory_limit', '3048M');
ini_set('post_max_size', '32M');
ini_set('max_input_time', 999);
ini_set('max_execution_time',999);
ini_set('display_errors',1);
set_time_limit(0);
error_reporting(E_ALL);
// magento specific connection info
@pkdavies
pkdavies / metafix.php
Created December 5, 2012 15:09
META data updater for Mageworx SEO Ultimate
<?php
/**
* Magento META data populator for us with Mageworx SEO Suite Ultimate.
* Copyright Juicy Media Ltd
*
* Features:
* -> wipes META description and title
* -> updates META keywords based on product description
*
* Usage:
@pkdavies
pkdavies / SUPEE-662_EE_1.12.0.2_v2.patch
Created December 18, 2012 12:49
Magento rounding issue patch file
diff --git app/code/core/Mage/Core/Model/Store.php app/code/core/Mage/Core/Model/Store.php
index 66a94f5..1a146a5 100644
--- app/code/core/Mage/Core/Model/Store.php
+++ app/code/core/Mage/Core/Model/Store.php
@@ -106,6 +106,12 @@ class Mage_Core_Model_Store extends Mage_Core_Model_Abstract
*/
const MEDIA_REWRITE_SCRIPT = 'get.php/';
+
+ /**
diff --git app/code/core/Mage/Paypal/Model/Ipn.php app/code/core/Mage/Paypal/Model/Ipn.php
index 730d09b..eb5f0e0 100644
--- app/code/core/Mage/Paypal/Model/Ipn.php
+++ app/code/core/Mage/Paypal/Model/Ipn.php
@@ -139,8 +139,20 @@ class Mage_Paypal_Model_Ipn
$this->_debugData['postback'] = $sReq;
$this->_debugData['postback_to'] = $this->_config->getPaypalUrl();
+ /**
+ * Array of http headers required by PayPal
<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
@pkdavies
pkdavies / SUPEE-991_EE_1.12.0.2_v1.patch
Created January 31, 2013 09:45
workaround in case if item subtotal precision is not compatible with PayPal (.2)
diff --git app/code/core/Mage/Paypal/Model/Cart.php app/code/core/Mage/Paypal/Model/Cart.php
index 999d3b8..4d625ca 100644
--- app/code/core/Mage/Paypal/Model/Cart.php
+++ app/code/core/Mage/Paypal/Model/Cart.php
@@ -281,9 +281,11 @@ class Mage_Paypal_Model_Cart
// regular items from the sales entity
$this->_items = array();
+ $excludeTaxSum = 0;
foreach ($this->_salesEntity->getAllItems() as $item) {