Skip to content

Instantly share code, notes, and snippets.

@Vinai
Vinai / MCACE-22.patch
Created June 3, 2011 07:48
MCA-CE MCACE-22: Quotes with a Subtotal of 0.00 and a Shipping Method Cost > 0.00 can't be ordered
diff --git a/app/code/core/Mage/Payment/Block/Form/Container.php b/app/code/core/Mage/Payment/Block/Form/Container.php
index 9b505bb..ca4b95b 100644
--- a/app/code/core/Mage/Payment/Block/Form/Container.php
+++ b/app/code/core/Mage/Payment/Block/Form/Container.php
@@ -116,7 +116,7 @@ class Mage_Payment_Block_Form_Container extends Mage_Core_Block_Template
$quote = $this->getQuote();
$store = $quote ? $quote->getStoreId() : null;
$methods = $this->helper('payment')->getStoreMethods($store, $quote);
- $total = $quote->getBaseSubtotal();
+ $total = $quote->getBaseGrandTotal();
@Vinai
Vinai / gist:1205913
Created September 9, 2011 10:32
Bug with store cookie handling in Magento up to 1.6 if specifying a non-default store MAGE_RUN_CODE
--- a/app/code/core/Mage/Core/Model/App.php
+++ b/app/code/core/Mage/Core/Model/App.php
@@ -511,11 +511,7 @@ class Mage_Core_Model_App
if ($this->_currentStore == $store) {
$store = $this->getStore($store);
- if ($store->getWebsite()->getDefaultStore()->getId() == $store->getId()) {
- $this->getCookie()->delete(Mage_Core_Model_Store::COOKIE_NAME);
- } else {
- $this->getCookie()->set(Mage_Core_Model_Store::COOKIE_NAME, $this->_currentStore, true);
@Vinai
Vinai / setup.php
Created November 8, 2011 20:35
Example EAV setup script using createEntityTables(), installEntities() and addAttribute()
<?php
/* @var $installer Mage_Eav_Model_Entity_Setup */
$installer = Mage::getModel('eav/entity_setup', 'default_setup');
$installer->startSetup();
// Example createEntityTables() call
$installer->createEntityTables('example_supplier');
#!/bin/bash
# CREATE BACKUPS BEFORE RUNNING THIS SCRIPT!
for m in $(locate Mage.php | grep -v downloader); do
cd $(dirname $(dirname $m)) || (echo && continue) # old locate db
MAGE_VERSION=$(php -d error_reporting=0 -r "require 'app/Mage.php'; Mage::app(); echo Mage::getVersion();")
if echo $MAGE_VERSION | egrep -q "^[0-9.]+$"; then
if [ $MAGE_VERSION "<" 1.4.0.0 ] || [ $MAGE_VERSION ">" 1.7.0.1 ]; then
echo -e "No patch available for version $MAGE_VERSION in $(pwd)\n"
@Vinai
Vinai / CartController.php
Created July 11, 2012 14:57
Your/Ext/etc/config.xml and Your/Ext/controllers/Checkout/CartController.php
<?php
// Your/Ext/controllers/Checkout/CartController.php
class Your_Ext_Checkout_CartController extends Mage_Checkout_CartController
{
public function yourNewAction()
{
}
}
@Vinai
Vinai / releases.txt
Last active July 6, 2021 05:24
Magento Release Dates
Major Magento Releases
CE 1.0 (Mar 2008)
CE 1.1 (Jul 2008)
CE 1.2 (Dec 2008)
CE 1.3 (Apr 2009)
EE 1.6 (Nov 2009)
EE 1.7 (Jan 2010)
CE 1.4 (Feb 2010)
EE 1.8 (Apr 2010)
@Vinai
Vinai / fix-url-keys.php
Last active September 2, 2022 16:24
This fixes the duplicate url_key issue in a Magento 1.8 / 1.13 installation.
<?php
/**
* Drop this into the shell directory in the Magento root and run with -h to see all options.
*/
require_once 'abstract.php';
/**
* Fix duplicate url keys for categories and products to work with the 1.8 alpha1 CE url key constraints.
@Vinai
Vinai / 1.factory-methods.md
Last active July 6, 2021 05:25
Model & Resource Model Class Resolution Steps

Debugging (Resource) Model Instantiation

Follow each step manually and any bugs during (resource) model instantiation will become obvious.

Since many people find model and resource model instantiation to be one of the more challenging things in Magento 1, these are all the steps Magento does to resolve the factory name to the real PHP class name.

To debug, simply follow each step manually until you find a non-match. This works really well in my experience.
Less guessing, more and faster results.

In the examples I use a factory name of "example/thing".

@Vinai
Vinai / Observer.php
Created May 1, 2013 20:52
Example custom Magento profiler via Observer. Please keep in mind this is OLD CODE ;)
<?php
// app/code/local/Example/Profiler/Model/Observer.php
class Example_Profiler_Model_Observer
{
/**
* Log the profiler statistics plus some information that helps identify the request
*
* @param Varien_Event_Observer $observer
@Vinai
Vinai / boris-mage.php
Last active September 10, 2016 15:33
PHP REPL with initialized Magento environment
#!/usr/bin/env php
<?php
//
// PHP REPL with initialized Magento environment
//
// Thanks to https://github.com/d11wtq/boris
//
// Drop this script in your $PATH and run it anywhere in a Magento directory tree to start the REPL
//