Skip to content

Instantly share code, notes, and snippets.

@7ochem
7ochem / .vimrc
Last active October 13, 2015 02:18 — forked from Rud5G/vimrc.vim
.vimrc
" Vim RC
" Based upon Rud5G .vimrc
" @link https://gist.github.com/Rud5G
" @link https://gist.github.com/2316255
"
" Below some links that could help understand and edit this file
" @link http://vimdoc.sourceforge.net/htmldoc/options.html
" @link http://www.eng.hawaii.edu/Tutor/vi.html [BROKEN!]
" -> {@link http://www.linuxfocus.org/English/May2000/article153.shtml}
"
@7ochem
7ochem / .bashrc
Last active October 13, 2015 07:27 — forked from Rud5G/gist:3496231
.bashrc
## here is the original ~/.bashrc
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
@7ochem
7ochem / git_mass_file_commands.sh
Last active December 11, 2015 17:18
Different shell command to mass add files to your git commit
# This is the base of the commands below. This adds all files appearing in git status:
git status -s |grep -E "^.[^D] " |sed "s/^.. //" |xargs git add
git status -s |grep -E "^.D " |sed "s/^.. //" |xargs git rm | wc -l
# For a simple add all (no deletions) you probably want to use this
# (add all files * and all dot files .[!.]*, asterix won't match dot files):
git add * .[!.]*
# These commands rely on the short GIT status output "git status -s"
# Short status line syntax is "XY myfile"
# X (first char) displays the status for a file in the staging area
(MySQLDUMP_DATABASE=$(sed -n 's/^.*<dbname><!\[CDATA\[\(.*\)\]\]><\/dbname>.*/\1/p' app/etc/local.xml | head -n1) \
&& \
mysqldump -h$(sed -n 's/^.*<host><!\[CDATA\[\(.*\)\]\]><\/host>.*/\1/p' app/etc/local.xml | head -n1) \
-u$(sed -n 's/^.*<username><!\[CDATA\[\(.*\)\]\]><\/username>.*/\1/p' app/etc/local.xml | head -n1) \
-p$(sed -n 's/^.*<password><!\[CDATA\[\(.*\)\]\]><\/password>.*/\1/p' app/etc/local.xml | head -n1) \
$MySQLDUMP_DATABASE \
--ignore-table=${MySQLDUMP_DATABASE}.core_cache \
--ignore-table=${MySQLDUMP_DATABASE}.core_cache_tag \
--ignore-table=${MySQLDUMP_DATABASE}.log_url \
--ignore-table=${MySQLDUMP_DATABASE}.log_url_info \
<?php
// Init framework
require 'app/Mage.php';
Mage::app();
// Factory methods to search for
$methods = array(
'Mage::helper',
'Mage::getModel',
'Mage::getResourceModel',
#!/usr/bin/php -q
<?php
ini_set('display_errors', 1);
require_once('./app/Mage.php');
Mage::init();
Mage_Core_Model_Resource_Setup::applyAllUpdates();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
@7ochem
7ochem / magento_mage_upgrade.sh
Created March 8, 2013 10:53
Upgrade Magento from 1.6 to 1.7+
#!/bin/sh
# From http://www.magentocommerce.com/wiki/magento_upgrade_from_1.6.0_1.6.1_or_1.6.2._to_1.7.0.0
rm -rf var/cache/* var/session/* var/full_page_cache/*
chmod +x ./mage
./mage mage-setup .
./mage config-set preferred_state stable
./mage list-installed
@7ochem
7ochem / magento_store_info.sql
Created March 19, 2013 16:29
Get all Magento stores with base url and design configuration in one query output
SELECT cw.`website_id`, cw.`code` AS `website_code`, cw.`name` AS `website_name`,
cw.`is_default` AS `website_is_default`, cw.`default_group_id` AS `website_default_group_id`,
csg.`group_id`, csg.`name` AS `group_name`, csg.`default_store_id` AS `group_default_store_id`,
cs.`store_id`, cs.`code` AS `store_code`, cs.`name` AS `store_name`, cs.`is_active` AS `store_is_active`,
ccd_base_url.`value` AS `base_url`, ccd_base_url.`scope_scope_id` AS `base_url_scope`,
ccd_design_package.`value` AS `design_package`, ccd_design_package.`scope_scope_id` AS `design_package_scope`,
ccd_design_theme_layout.`value` AS `design_theme_layout`, ccd_design_theme_layout.`scope_scope_id` AS `design_theme_layout_scope`,
ccd_design_theme_template.`value` AS `design_theme_template`, ccd_design_theme_template.`scope_scope_id` AS `design_theme_template_scope`,
ccd_design_theme_skin.`value` AS `design_theme_skin`, ccd_design_theme_skin.`scope_scope_id` AS `design_theme_skin_scope`
FROM `core_store` AS cs
@7ochem
7ochem / testXml.php
Created July 9, 2013 11:46
Test your Magento XML files from command line with this tool and see all errors (if any)
#!/usr/bin/php
<?php
/**
* Debug an XML file
* @author Jochem Klaver <j.klaver@drecomm.nl>
* @link http://php.net/libxml
*/
require('app/Mage.php');
Mage::app();

Magento Snippets

Set all Images to first position as default

UPDATE catalog_product_entity_media_gallery AS mg,
    catalog_product_entity_media_gallery_value AS mgv,
    catalog_product_entity_varchar AS ev
SET ev.value = mg.value
WHERE  mg.value_id = mgv.value_id