Skip to content

Instantly share code, notes, and snippets.

View steverobbins's full-sized avatar

Steve Robbins steverobbins

View GitHub Profile
select p1.sku `parent sku`, group_concat(p2.sku) `associated skus`, lt.code `type`
from catalog_product_link l
inner join catalog_product_entity p1 on p1.entity_id = l.product_id
inner join catalog_product_entity p2 on p2.entity_id = l.linked_product_id
inner join catalog_product_link_type lt on l.link_type_id = lt.link_type_id
group by l.product_id
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""
select
`Time Period`,
round(avg(num), 1) `Average Number of Orders`
from (
select
date_format(date_sub(o.created_at, interval 8 hour), "%l:00 - %l:59 %p PST") `Time Period`,
count(*) num,
date_format(date_sub(o.created_at, interval 8 hour), "%H") sort
from sales_flat_order o
where o.created_at > '2016-01-01 00:00:00'
@steverobbins
steverobbins / magentoSmartIndexCacheRefresh.sh
Last active July 11, 2017 04:31
A Magento 1 script that will only reindex and refresh caches that have been invalidated.
#!/bin/bash
# Smart Magento reindexing and cache clearing. Only indexes and caches that are
# invalidate are cleared. Place this file in your shell/ directory and make it
# executable: chmod +x magentoSmartIndexCacheRefresh.sh
#
# Before use it is recommended to consider your failures as a developer due to
# lack of ability to correctly update individual indexes and caches as records
# modified processed.
#
#!/bin/bash
bash_prompt() {
local NONE="\[\033[0m\]" # unsets color to term's fg color
# regular colors
local K="\[\033[0;30m\]" # black
local R="\[\033[0;31m\]" # red
local G="\[\033[0;32m\]" # green
local Y="\[\033[0;33m\]" # yellow
<?php
include 'app/Mage.php';
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::app($mageRunCode, $mageRunType);
<?php
ini_set('display_errors', 1);
include 'app/Mage.php';
Mage::setIsDeveloperMode(true);
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::app($mageRunCode, $mageRunType);
$mail = new Zend_Mail();
#!/bin/bash
if [[ -e ../../app/etc/local.xml ]]
then
if [[ ! -d ../../var/support ]]
then
mkdir ../../var/support ||
if [[ $? != 0 ]]
then
lock '3.4.0'
set :application, 'magento'
set :repo_url, 'git@example.com:company/repo.git'
set :keep_releases, 10
app_symlinks = ['app/etc/local.xml', 'media', 'var']
namespace :magento do
desc 'Symlink shared files and folders'
select eet.entity_type_code, sf.store_id, max(sf.increment_id) real_increment_last_id, ees.increment_last_id, if(ees.increment_last_id >= max(sf.increment_id), 'Yes', 'No') healthy
from sales_flat_shipment sf
inner join eav_entity_store ees on ees.store_id = sf.store_id
inner join eav_entity_type eet on eet.entity_type_id = ees.entity_type_id
where eet.entity_type_code = 'shipment'
group by sf.store_id, eet.entity_type_code
union all
select eet.entity_type_code, sf.store_id, max(sf.increment_id) real_increment_last_id, ees.increment_last_id, if(ees.increment_last_id >= max(sf.increment_id), 'Yes', 'No') healthy
from sales_flat_invoice sf
inner join eav_entity_store ees on ees.store_id = sf.store_id