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 / Magento-Average-Orders-Average-Discounts-Totals-by-Month-Year.sql
Created January 31, 2014 02:41
Magento get average order, discount, item count, and order amount break down by month and year with direct SQL
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,
YEAR(so.created_at) AS year_ordered,
@tegansnyder
tegansnyder / Sales-by-category.sql
Created January 9, 2014 16:00
Finding the category that has the most sales in Magento
SELECT cat_id, SUM(row_total) as total_sales_by_cat, cv.value FROM (
SELECT c2.entity_id as cat_id, si.row_total
FROM catalog_category_product c1
INNER JOIN catalog_category_entity_varchar c2 ON (c1.category_id = c2.entity_id)
INNER JOIN catalog_product_entity c3 ON (c1.product_id = c3.entity_id)
INNER JOIN sales_flat_order_item si ON (si.product_id = c3.entity_id)
WHERE c2.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'name' AND entity_type_id = 3)
ORDER BY si.created_at DESC
) main
INNER JOIN catalog_category_entity_varchar cv ON (cv.entity_id = cat_id)
@tegansnyder
tegansnyder / Magento Admin Backend.md
Last active January 15, 2021 12:51
Magento Custom Admin Backend

You can set your own custom Magento admin URL in:

System -> Configuration -> [ADVANCED] -> Admin -> Admin Base URL

NOTE: Make sure you have added a ServerAlias directive to your virtual host configuration for backend.domain.com and that you have a SSL cert or wildcart setup for HTTPS traffic on that subdomain or you will lock yourself out the admin.

Rules for your .htaccess file to prevent duplicate urls and redirect directly to admin dashboard:

@tegansnyder
tegansnyder / CategoryTreePathExportMagento.php
Last active December 3, 2020 15:31
Export Category Tree and Paths for Magento
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
$category = Mage::getModel ('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
@tegansnyder
tegansnyder / Using PHP ZTS (Zend Thread Safety) module and pthreads on PHP7 Webstatic Repo (Centos-RHEL).md
Last active November 20, 2020 13:06
Using PHP ZTS (Zend Thread Safety) module and pthreads on PHP7 Webstatic Repo (Centos/RHEL)

BECOM SUDO USER:

sudo -s

INSTALL WEBSTATIC REPO FOR CENTOS/RED HAT 7:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
@tegansnyder
tegansnyder / Magento-EE-Indexer-Status.sql
Created August 27, 2014 21:57
Get the Status of Magento Enterprise Indexers with MySQL
SELECT `main_table`.`process_id`,
`main_table`.`indexer_code`,
'community' AS `indexer_type`,
`main_table`.`status`,
`main_table`.`started_at`,
`main_table`.`ended_at`,
`main_table`.`mode`,
IF(e.events IS NULL, 0, e.events) AS `events`
FROM `index_process` AS `main_table`
LEFT JOIN
@tegansnyder
tegansnyder / Upgrading Elastic Search to 2.3 - Steps I took.md
Last active June 2, 2020 11:58
Upgrading Elastic Search to 2.3 - Steps I took

Details of steps I took on each node in a nine node ES cluster on RHEL7. These steps need to occur one node at a time, i.e. "rolling upgrade")

Step 1: Disable shard allocation

curl -XPUT "http://localhost:9200/_cluster/settings" -d'
{
  "transient": {
    "cluster.routing.allocation.enable": "none"
  }
}'
@tegansnyder
tegansnyder / Install go 1.6 RHEl 7.md
Last active February 8, 2020 07:47
Install go 1.6 RHEl 7
# download latest https://golang.org/dl/
wget https://storage.googleapis.com/golang/go1.6.3.linux-amd64.tar.gz
tar xzvf go1.6.3.linux-amd64.tar.gz

# system wide install
sudo mv go /usr/local/

# add system wide path
@tegansnyder
tegansnyder / category-path-skus-query.md
Created November 20, 2014 14:45
List the Magento Skus and the Category Paths they belong in

Find a list of magento sku's and the category paths they belong in via MySQL query.

SELECT product_id, sku, catid, cce.path FROM (
    SELECT entity_id as product_id, category_id as catid FROM (
        SELECT `e`.entity_id, `at_category_id`.`category_id` 
        FROM `catalog_product_entity` AS `e` 
        LEFT JOIN `catalog_category_product` AS `at_category_id`
        ON (at_category_id.`product_id`=e.entity_id)
    ) sub_query
) final_query
@tegansnyder
tegansnyder / Flushing DNS cache macOSX Sierra.sh
Created December 29, 2016 15:30
Flushing DNS cache macOSX Sierra
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say flushed