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 / exportCats.php
Created March 18, 2014 17:26
Export Categorys
<?php
require_once 'app/Mage.php';
Mage::app();
$x = 0;
$categories = array();
$csv = array();
@tegansnyder
tegansnyder / no-results-search-breakdown.sql
Created March 19, 2014 21:46
Search result counts (no results) breakdown by year/month
SELECT COUNT(query_id) AS no_results_count,
y,
m
FROM
(SELECT cq.query_id,
MONTH(cq.updated_at) AS m,
YEAR(cq.updated_at) AS y
FROM catalogsearch_query cq
WHERE cq.num_results = 0
ORDER BY cq.popularity DESC) sub_query
@tegansnyder
tegansnyder / average-orders-per-customer.sql
Created March 31, 2014 14:44
Average orders per customer
SELECT AVG(num_orders) FROM (
SELECT COUNT(customer_id) as num_orders, customer_id FROM sales_flat_order
GROUP BY customer_id) as sub
<?php
/**
* Optimized version of attribute source options model
*
* That allows to preload options once and reuse them instead of doing calls to db all the time
*
*/
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table
extends Mage_Eav_Model_Entity_Attribute_Source_Table
@tegansnyder
tegansnyder / redis-setup.sh
Created June 10, 2014 17:57
Redis setup script for multiple instances on different ports
#!/bin/bash
# make sure this script is executable
# place in /var/redis/
# run by issuing: ./redis-setup.sh PORT_NUMBER
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@tegansnyder
tegansnyder / uk-theme-data.sql
Created June 18, 2014 03:08
Grab UK theme info
SELECT * FROM (
SELECT * FROM core_config_data WHERE path NOT IN ("design/theme/layout_ua_regexp", "design/theme/skin_ua_regexp", "design/theme/default_ua_regexp", "design/theme/template_ua_regexp")
) c
WHERE c.path LIKE "%design/package%" OR c.path LIKE "%design/theme/default%" OR c.path LIKE "%design/theme/template%" OR c.path LIKE "%design/theme/skin%" OR c.path LIKE "%design/theme/layout%"
@tegansnyder
tegansnyder / Mage_Googlecheckout_Helper_Data.md
Created June 18, 2014 03:47
Mage_Googlecheckout_Helper_Data upgrade error

If you get error after upgrading to 1.14.0.1

PHP Fatal error:  Class 'Mage_Googlecheckout_Helper_Data' not found in /var/www/app/Mage.php on line 547, referer: http://site.com/index.php/admin/dashboard/

edit:

app/code/core/Mage/GoogleCheckout/etc/system.xml
@tegansnyder
tegansnyder / products-default-cat.sql
Created June 24, 2014 13:49
Products in Default Category
SELECT cp.product_id, pf.sku, pf.name, pf.thumbnail, pf.short_description, pf.price, pf.special_price F
ROM catalog_category_entity cc
JOIN catalog_category_product cp ON cc.entity_id = cp.category_id
JOIN catalog_product_flat_1 pf ON pf.entity_id = cp.product_id
WHERE path = '1/2'
@tegansnyder
tegansnyder / caps-customers.php
Created June 25, 2014 16:01
Create 100 CAPS Testing Magento accounts
<?php
require_once('app/Mage.php');
umask(0);
Mage::app();
$store_id = Mage::app()->getStore()->getId();
$customer_fname = 'CAPS';
$customer_lname = 'TEST';
@tegansnyder
tegansnyder / average_orders.sql
Created July 2, 2014 19:06
Average Orders per Month and Base Total
SELECT AVG(average_base_subtotal), AVG(total_orders) FROM (
SELECT sub_query.month_ordered,
sub_query.year_ordered,
AVG(sub_query.base_subtotal) AS average_base_subtotal,
AVG(sub_query.discount_amount) AS average_discount_amt,
AVG(sub_query.order_qty) AS average_total_item_count,
COUNT(sub_query.entity_id) AS total_orders
FROM
(SELECT so.entity_id,
MONTH(so.created_at) AS month_ordered,