Skip to content

Instantly share code, notes, and snippets.

@tmbritton
tmbritton / casper.js test test
Created January 30, 2014 04:57
casper.js testing test
/**
* Casper.js testing test
*/
var testSuite = {
config: {
baseUrl: 'http://www.wholefoodsmarket.com',
},
googleTest: function(){
@bastianccm
bastianccm / persistent.php
Created July 2, 2014 12:29
Persistent Magento
<?php
// put in magento root folder
// run via
// rm /tmp/magento; php persistent.php
// output is in /tmp/magento.log
function plog($msg) {
file_put_contents('/tmp/magento.log', date('H:i:s') . ': ' . $msg . PHP_EOL, FILE_APPEND);
}
@turanct
turanct / functional-tests.php
Created February 11, 2015 14:50
Simple test framework, functional programming style
<?php
function within($topic, ...$features)
{
return function($do = 'getFailedAssertions') use ($topic, $features) {
if ($do === 'getName') {
return $topic;
} elseif ($do === 'getFailedAssertions') {
return array_reduce(
$features,
@LeeSaferite
LeeSaferite / gist:662396
Created November 4, 2010 12:36
Mage_PayPal fix for versions prior to 1.4
diff --git a/app/code/core/Mage/Paypal/Model/Standard.php b/app/code/core/Mage/Paypal/Model/Standard.php
index e77e3d8..e70efea 100644
--- a/app/code/core/Mage/Paypal/Model/Standard.php
+++ b/app/code/core/Mage/Paypal/Model/Standard.php
@@ -368,8 +368,16 @@ class Mage_Paypal_Model_Standard extends Mage_Payment_Model_Method_Abstract
*/
} else {
-
- if ($this->getIpnFormData('mc_gross')!=$order->getBaseGrandTotal()) {
@SchumacherFM
SchumacherFM / copy-store-view.sql
Created June 6, 2013 14:48
Magento - Copy Store Views / Some tables are still missing
-- idea: rebuild this via php and use mysql.information_schema to automatically figure out tables with column store_id resp. website_id
-- maybe include it into n98-magerun
# DEFINE
SET @to_store := 8;
SET @to_website := 4;
SET @from_store := 2;
SET @from_website := 3;
@drewdhunter
drewdhunter / Magento - core code pre commit hook
Last active December 31, 2015 20:08
Pre commit hook useful for Magento projects
#!/usr/bin/env bash
set -eu
declare -a file_patterns=('app/code/core' 'app/Mage.php$' '^index.php$')
exit_status=0
while read x file; do
for file_pattern in ${file_patterns[@]}; do
if [[ $file =~ $file_pattern ]]; then
@edannenberg
edannenberg / magentrolol.md
Last active January 26, 2017 17:41
Magento 1.8.x tax calculation when using prices including tax.

We upgraded to 1.8 a couple of weeks ago, today i had to investigate this little gem:

trolol

The issue was reproducable by adding 3 of the above items to the cart, checking the db confirmed that the 2nd quote item already had the wrong tax value.

Digging down the culprit turned out to be in Mage_Tax_Model_Sales_Total_Quote_Subtotal and Mage_Tax_Model_Sales_Total_Quote_Tax:

collect() will call for each quote item:

@IvanChepurnyi
IvanChepurnyi / Observer.php
Created September 16, 2013 22:31
Optimized catalog price rules
<?php
class EcomDev_Optimization_Model_Rule_Observer extends Mage_CatalogRule_Model_Observer
{
protected $_preloadedPrices = array();
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
$quote = $observer->getQuote();
$date = Mage::app()->getLocale()->storeTimeStamp($quote->getStoreId());
@IvanChepurnyi
IvanChepurnyi / optimize-composer.sh
Created September 30, 2016 16:00
Optimizes autoloader for the best performance on production system
#!/bin/bash
magentodir=$1
cd $magentodir
read -d '' script << PHP
<?php
\$composer = json_decode(file_get_contents('composer.json'), true);
if (!is_array(\$composer['autoload']['psr-0'][''])) {
@IvanChepurnyi
IvanChepurnyi / config.xml
Created November 5, 2013 09:37
Disable Mage_Log module observers
<config>
<frontend>
<controller_action_predispatch>
<observers>
<log>
<type>disabled</type>
</log>
</observers>
</controller_action_predispatch>
<controller_action_postdispatch>