Skip to content

Instantly share code, notes, and snippets.

@mpchadwick
mpchadwick / enabled-categories-with-no-products.sql
Created December 7, 2015 20:07
Magento Enabled Categories with No Products
# Replace the attribute IDs as needed
SELECT
cce.entity_id AS "Category ID",
cce.path as "Category Path",
ccev.value as "Category Name",
COUNT(ccp.product_id) as "Number of Products"
FROM catalog_category_entity cce
INNER JOIN catalog_category_entity_varchar ccev
ON cce.entity_id = ccev.entity_id
@mpchadwick
mpchadwick / magento-deadlock-simulation.sql
Last active December 15, 2015 15:17
Simulate a Deadlock in Magento
# Run the following queries
set transaction isolation level serializable;
# In the admin
start transaction;
select * from core_config_data;
# load the system configuration
# On the frontend
start transaction;
@mpchadwick
mpchadwick / cw-text-fix.js
Created November 6, 2015 19:50
ConnectWise Text Fix
var cells = document.querySelectorAll('.day-info-cell[style^="background: rgb(0, 0, 255);"] div');
function setBackgroundWhite(element) {element.style.color = "white"}; Array.prototype.forEach.call(cells, setBackgroundWhite);
@mpchadwick
mpchadwick / OrdersWithoutStatusHistory.sql
Last active November 5, 2015 16:09
Orders Without Status History
# Get the number or orders without any status history
# Can be useful for debugging (e.g. it is expected that there is a status history such as "Authorize Amount"
SELECT
date(result.created_at),
count(result.entity_id) as Orders,
SUM(CASE WHEN result.comments IS NULL THEN 1 ELSE 0 END) as OrdersWithoutStatuses,
CONCAT(FLOOR(100 * SUM(CASE WHEN result.comments IS NULL THEN 1 ELSE 0 END) / count(result.entity_id)), '%') PercentageWithoutStatuses
FROM (
SELECT
@mpchadwick
mpchadwick / SUPEE6788Checklist.md
Last active November 10, 2015 16:44
SUPEE-6788 Checklist

SUPEE-6788 CHECKLIST

  • Base patch installed
  • Template changes integrated to custom theme
    • customer/form/register.phtml
    • customer/form/resetforgottenpassword.phtml
    • persistent/customer/form/register.phtml
    • page/js/cookie.phtml
  • Layout change (customer.xml) integrated to custom theme
  • SDUPEE-8766 applied (curl -sS https://raw.githubusercontent.com/sdinteractive/SDUPEE-8766/master/SDUPEE-8766.diff | git apply)
  • APPSEC-1063 incompatibilities fixed
@mpchadwick
mpchadwick / query.sql
Last active August 29, 2015 14:27
Mageto Improved Autocomplete Query
#################################################################
# ORIGINAL
# Then the term matching the search is plucked to the top in PHP
# This eliminates the ability to put a "limit" on the result set
#################################################################
SELECT
DISTINCT IFNULL(synonym_for, query_text) AS `query`,
`main_table`.`num_results`,
`main_table`.*
FROM `catalogsearch_query` AS `main_table`
@mpchadwick
mpchadwick / configurable_best_sellers.sql
Created August 16, 2015 16:52
Magento Best Sellers - Configurable Products
SELECT
cpf.entity_id,
cpf.name,
cpf.type_id,
(
SELECT SUM(sbam.qty_ordered)
FROM sales_bestsellers_aggregated_monthly sbam
LEFT JOIN catalog_product_super_link cpsl
ON cpsl.product_id = sbam.product_id
WHERE sbam.product_id = cpf.entity_id
@mpchadwick
mpchadwick / Mpchadwick_Missing_Acl_Checker.php
Created July 11, 2015 03:42
Mpchadwick_Missing_Acl_Checker.php
<?php
require_once 'abstract.php';
/**
* Generate a CSV of modules with admin routes that haven't implemented _isAllowed()
*/
class Mpchadwick_Missing_Acl_Checker extends Mage_Shell_Abstract
{
const MODULES_PATH = 'modules';
@mpchadwick
mpchadwick / Massive Dropdown Attribute
Last active August 29, 2015 14:17
Massive Dropdown Attribute
########################################
# Set Up A Masssive Dropdown Attribute
########################################
# User defined vars
SET @num_options = 3500;
SET @attribute_code = 'massive_attribute';
SET @attribute_label = 'Massive Attribute';
SET @store_id = 0;
@mpchadwick
mpchadwick / gist:9076670
Created February 18, 2014 18:22
Feedmagnet API
<!-- simple CSS styling for sidebar and updates -->
<style>
.fm-update { margin-bottom: 20px; border-bottom: 1px #ddd; }
.avatar { float: left; margin-right: 10px; height: 48px; width: 48px; }
.author { font-size: 1.2em; padding-top: 5px; }
.timestamp { font-size: .8em; color: #777; }
.text { margin-top: 20px 0; }
.social-feed {
width: 33%;
float: left;