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 / debugging reindex locks mysql commands.md
Created December 2, 2014 23:57
Useful Mysql Commands for Debugging Magento Reindex Locks

Sometimes you may have a run away reindex process that aborted due to a MySQL connection error of some sorts. It may be useful to use the following MySQL commands to aid in debugging.

Determining if a lock exists

Magento Enterprise labels the reindex lock via the constant REINDEX_FULL_LOCK in app/code/core/Enterprise/Index/Model/Observer.php

SELECT IS_FREE_LOCK('mydatabase_name.reindex_full')

Returns 1 is specified lock is free and can be acquired, 0 if it’s in use, NULL if an error occurs.

Determing the thread that is holding the lock

@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 / hhvm_magento_setup.md
Last active July 14, 2023 22:30
HHVM Magento Server Setup

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
@tegansnyder
tegansnyder / delete a order.php
Created November 6, 2014 22:20
Delete and order by increment id
<?php
require_once('app/Mage.php');
umask(0);
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
Mage::getModel('sales/order')->loadByIncrementId('200000065')->delete();
@tegansnyder
tegansnyder / hhvm-exclude-directory.md
Last active December 29, 2015 05:02
Exclude a directory from being processed by HHVM (HHVM Bypass for PHP-FPM)

I was looking for a way to load certain files using regular PHP and mix and match HHVM with PHP-FPM. Here is an example of how to use PHP-FPM to process files in the /exclude/ directory and HHVM for all other files.

## Use regular ol' PHP for files in this directory
location ^~ /exclude/ {
  include fastcgi_params;
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  break;
@tegansnyder
tegansnyder / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
/**
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and
* then use this script to apply updates and refresh the config cache without
* causing a stampede on the config cache.
*
* @author Colin Mollenhour
*/
umask(0);
ini_set('memory_limit','512M');
@tegansnyder
tegansnyder / hhvm-rhel6.md
Created November 4, 2014 01:59
Installing HHVM on RHEL 6
cd /etc/yum.repos.d
sudo wget http://www.hop5.in/yum/el6/hop5.repo

# find what versions are available
yum list --showduplicates hhvm

# install latest version
yum install hhvm-3.2.0-1.el6
@tegansnyder
tegansnyder / Global Scoped System Configuration Settings Magento.md
Created November 3, 2014 19:14
List of all GLOBAL scoped system configuration settings in Magento Enterprise 1.14.0.1

Here is a list of all global scoped Magento system configuration settings found in EE 1.14.0.1. Please let me know if I missed anything. The goal is this list is to show you what can't be changed at a website level.

GLOBAL scoped configs:

  • Category Flat Index
  • Product Flat Index
  • Price and Stock Index
  • Category Permissions
  • CMS Page Hierarchy
  • CMS Versioning
@tegansnyder
tegansnyder / Nominal-addItem.php
Created November 3, 2014 18:44
Nominal Item addItem function from app/code/core/Mage/Sales/Model/Quote.php
<?php
/**
* Adding new item to quote
*
* @param Mage_Sales_Model_Quote_Item $item
* @return Mage_Sales_Model_Quote
*/
public function addItem(Mage_Sales_Model_Quote_Item $item)
{
/**