Skip to content

Instantly share code, notes, and snippets.

@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;
@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 / 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 / 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 / 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 / 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 / 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-catalog-product-list-api-first-1000-products.php
Created December 9, 2015 21:34
Magento Catalog Product List API First 1000 Products
<?php
$client = new SoapClient('https://example.com/api/v2_soap?wsdl');
$session = $client->login('my_user_name', 'my_password');
$result = $client->catalogProductList($session, array(
'complex_filter' => array(
array(
'key' => 'product_id',
'value' => array('key' => 'from', 'value' => '1')
@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 / Non Sucky YouTube Embed
Created November 27, 2013 03:00
This directive lets you easily embed YouTube videos in your ng-app with out the performance suckiness of YouTube's iFrame embed code (which forces users to download 400K of data before even pressing play). This directive first finds and displays the video's thumbnail based on the id attribute, and only swaps in the iframe when the thumbnail is c…
directive('nonSuckyYoutubeEmbed', function factory() {
var directiveDefinitionObject = {
restrict: 'E',
template: '<div style="position: relative;">' +
'<img src="img/play-btn.png" style="position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin-left: -24px; margin-top: -24px; cursor: pointer;" alt="Play" />' +
'<img src="http://i.ytimg.com/vi/{{id}}/0.jpg" style="width: 100%; height: auto; display: inline; cursor: pointer" alt="" />' +
'</div>',
scope: {
id: '@id'
},