Skip to content

Instantly share code, notes, and snippets.

View tegansnyder's full-sized avatar
💭
Stay'n cold in Minnesota

Tegan Snyder tegansnyder

💭
Stay'n cold in Minnesota
View GitHub Profile
@tegansnyder
tegansnyder / handleBlockOutput.php
Created February 20, 2013 21:38
Amasty Customer Attributes Extension conflicts with Magento Paypal Express Payments by overriding the html block output on the Order Review page. Here is a quick fix.
<?php
// Edit your Amasty Custoemr Attributes
// Observer.php file
// find the handleBlockOutput function
public function handleBlockOutput($observer)
{
/* @var $block Mage_Core_Block_Abstract */
@tegansnyder
tegansnyder / UnserializeHack_sales_recurring_profiles.sql
Created April 7, 2013 19:05
Yes for some reason Magento serialized a bunch of arrays into the sales_recurring_profile tables. Using substring hacks we can get at some fields without having to use PHP to unserialize them.
SELECT
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(order_info,';',74),':',-1), '"', '') as coupon_code,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(order_info,';',6),':"',-1), '"', '') as order_created_at,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',22),':',-1), '"', '') as shipping_firstname,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',26),':',-1), '"', '') as shipping_lastname,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',32),':',-1), '"', '') as shipping_street,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',34),':',-1), '"', '') as shipping_city,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',36),':',-1), '"', '') as shipping_region,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',195),':',-1), '"', '') as shipping_state,
REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(shipping_address_info,';',40),':',-1), '"', '') as shipping_postcode,
@tegansnyder
tegansnyder / MailchimpMagentoEcommerce360.php
Created April 19, 2013 22:56
Mailchimp Ecommerce 360 for Magento Order Event Observer .... Some Code from ebizmart's extension.... but I just needed the Ecomerce360 aspect not all the other stuff there extension provides.
<?php
class Somecompany_Extensionname_Model_Observer extends Mage_Core_Model_Abstract {
public function mailchimpListen($observer) {
$thirty_days = time()+60*60*24*30;
if (isset($_REQUEST['mc_cid']) && isset($_REQUEST['mc_eid'])) {
setcookie('mc_campaign_id',trim($_REQUEST['mc_cid']), $thirty_days);
setcookie('mc_email_id',trim($_REQUEST['mc_eid']), $thirty_days);
@tegansnyder
tegansnyder / CustomerValue_and_SKUs-Magento-SQL-Query.sql
Created May 7, 2013 21:30
Get the the amount of money each customer has spent at your store along with all the skus of the products they have purchases in one SQL.
SELECT customer_id, customer_email, customer_firstname, customer_lastname, group_concat(si.sku SEPARATOR ',') as skus, SUM(subtotal_invoiced) AS cv
FROM sales_flat_order as so
INNER JOIN sales_flat_order_item AS si ON si.order_id = so.entity_id
GROUP BY customer_email
ORDER BY SUM(subtotal_invoiced) DESC
Date: Fri, 5 Jul 2013 22:41:03 -0500
Subject: [PATCH] Magento_CE_1.7.0.2_v1-CSRF_Patch
---
.../core/Mage/Catalog/Block/Product/Abstract.php | 85 ++++-
app/code/core/Mage/Catalog/Block/Product/View.php | 10 +-
.../core/Mage/Catalog/Helper/Product/Compare.php | 28 +-
app/code/core/Mage/Checkout/Helper/Cart.php | 26 +-
.../Mage/Checkout/controllers/CartController.php | 69 ++--
.../Checkout/controllers/OnepageController.php | 70 +++-
@tegansnyder
tegansnyder / varnish-vcl-config-example-non-www-redirect.txt
Created July 15, 2013 23:49
Varnish VCL configuration for redirecting non-www traffic to www
# added this to
sub vcl_recv {
if (req.http.host == "yourdomain.com") {
set req.http.Location = "http://www.yourdomain.com" + req.url;
error 750 "Permanently moved";
}
}
@tegansnyder
tegansnyder / local.xml
Created August 23, 2013 17:13
Example of loading a different head.phtml file for the Magento homepage
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<cms_index_index>
<action method="setTemplate" block="head"><tpl>page/html/headhomepage.phtml</tpl></action>
</cms_index_index>
<default>
<!-- rest of your local.xml -->
</default>
</layout>
@tegansnyder
tegansnyder / example-magento-build-script.sh
Created August 31, 2013 18:40
Example of a simple Magento build script using YUICompressor 2.4.7 and UgilifyJS2. This is just a rough example.
echo "* * * * * * * * * * * * * * * * * * * * *"
echo " Build Script v0.1"
echo " by Tegan Snyder"
echo "* * * * * * * * * * * * * * * * * * * * *"
echo ""
echo "combining css to mysite.css"
cat /store/skin/frontend/mytheme/theme/css/styles.css /store/skin/frontend/base/default/css/widgets.css /store/skin/frontend/mytheme/theme/css/skin.css /store/assets/css/jquery.modal.min.css > /store/css/mysite.css
echo "minifying combining css to mysite.min.css"
@tegansnyder
tegansnyder / List.php
Created September 13, 2013 17:26
Creating a Free Shipping Category in Magento. Step 1: create a basic Catalog Category in the Magento admin. Take note of the category_id. Step 2: Copy the Core file app/code/Core/Mage/Catalog/Block/Product/List.php to your local directory app/code/local/Mage/Catalog/Block/Product/List.php Step 3: Modify the _getProductCollection() function like …
<?php
/*
Rest of the file above this
app/code/local/Mage/Catalog/Block/Product/List.php
*/
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
<?php
<meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>" />
<title><?php echo $this->getTitle() ?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<?php
if (Mage::registry('current_product')) {
$current_product = Mage::registry('current_product');
$desc = preg_replace('/\s+?(\S+)?$/', '', substr(strip_tags(str_replace(array("\r\n", "\r", "\n"), "", $this->getDescription())), 0, 150));