Skip to content

Instantly share code, notes, and snippets.

View molotovbliss's full-sized avatar
⚗️
Code, Eat, Sleep++;

Jared molotovbliss

⚗️
Code, Eat, Sleep++;
  • DFW, Texas
View GitHub Profile
@molotovbliss
molotovbliss / triggers-magento-ee-1.14.2.3.sql
Created February 12, 2016 20:43
Magento Enterprise 1.14.2.3 Triggers.sql (no definer)
-- MySQL dump 10.13 Distrib 5.5.47, for debian-linux-gnu (x86_64)
--
-- created with:
-- mysqldump -u -p -n -d -t --skip-opt --no-create-info --triggers magentoee | sed -e 's/DEFINER=[^*]*\*/\*/' > triggers14.2.3.sql
--
-- Host: localhost Database: magentoee
-- ------------------------------------------------------
-- Server version 5.5.47-0ubuntu0.12.04.1
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
@molotovbliss
molotovbliss / gist:6120e22078a4757b5bb4
Created February 12, 2016 20:55
Handy Dandy Notebook of conditions for PHP
isset is_null ===null ==null empty
null | F | T | T | T | T |
unset | F | T | T | T | T |
"" | T | F | F | T | T |
[] | T | F | F | T | T |
0 | T | F | F | T | T |
false | T | F | F | T | T |
true | T | F | F | F | F |
1 | T | F | F | F | F |
\0 | T | F | F | F | F |
@molotovbliss
molotovbliss / truncate-colors.sql
Created February 16, 2016 01:21
Delete all color option values in Magento SQL
# Delete all color option values (attribute 80 default)
DELETE ov.*
FROM eav_attribute_option_value AS ov
JOIN eav_attribute_option AS o
ON o.option_id = ov.option_id
WHERE o.attribute_id = 80;
@molotovbliss
molotovbliss / gist:ab96de0ab5f208c1434e
Last active February 16, 2016 02:40 — forked from americkson/gist:17c1ffaeafa4a41eccef
Magento Enterprise 1.14 Clear Product Data
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_price_index`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_bundle_selection_price`;
TRUNCATE TABLE `catalog_product_bundle_stock_index`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
@molotovbliss
molotovbliss / attribute-remove.php
Last active April 9, 2016 23:29
Magento Shell Script that Removes a specific attribute via CLI argument.
<?php
/*
* Removes a specific attribute.
* [email protected]
*
* Usage: php -f attribute-remove.php [attribute_name]
*/
require_once 'abstract.php';
@molotovbliss
molotovbliss / admin-login.php
Created February 17, 2016 10:45
Magento admin login through bootstrapped script
<?php
require_once 'app/Mage.php';
umask(0);
$app = Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
// supply username
$user = Mage::getModel('admin/user')->loadByUsername('adminusername');
@molotovbliss
molotovbliss / assign-attribute-to-all-sets.sql
Created February 17, 2016 20:56
Assign a New Attribute to All Attribute Sets
INSERT INTO `eav_entity_attribute` (
`entity_type_id`,
`attribute_set_id`,
`attribute_group_id`,
`attribute_id`,
`sort_order`
)
(
SELECT
'ENTITY_TYPE_ID' AS entity_type_id,
@molotovbliss
molotovbliss / gist:d71f44c01b41c2b21d3c
Created March 4, 2016 15:43
Connect to Magento DB outside of Magento stack by reading local.xml with SimpleXML
<?php
/**
* Pull in the database details from the Magento configuration
*/
$localXml = __DIR__ .DS.'app/etc/local.xml';
if (file_exists($localXml)) {
// Load in the local.xml and retrieve the database settings
$xml = simplexml_load_file($localXml);
@molotovbliss
molotovbliss / closestNumber.php
Last active March 6, 2016 22:06
Find the closest number in an Array maintaining keys
<?php
// def closest (num, arr):
// curr = arr[0]
// foreach val in arr:
// if abs (num - val) < abs (num - curr):
// curr = val
// return curr
function closestnumber($number, $candidates) {
@molotovbliss
molotovbliss / index.php
Created March 10, 2016 19:28
Bypass Maintenance Mode in Magento with custom HTTP_USER_AGENT
Overwrite the maintenance change in index.php file conditional with the follow, using a more unique User Agent is recommended.
Chrome/Firefox/etc. most browsers offer means via extensions or development tools to set a customer User Agent. Utliziing this
you can bypass the maintance mode for Testing when you don't have a Static IP:
# If user agent is "QA" bypass maintenance mode (customize user agent for more uniqueness)
if (file_exists($maintenanceFile) && $_SERVER['HTTP_USER_AGENT'] != "QA") {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}