Skip to content

Instantly share code, notes, and snippets.

View cmuench's full-sized avatar

Christian Münch cmuench

View GitHub Profile
@cmuench
cmuench / module_structure.txt
Created January 27, 2012 11:20
Puppet to install PHPStorm
modules
└── dev-tools
├── files
│   └── phpstorm.vmoptions
├── templates
│   └── phpstorm.desktop.erb
└── manifests
├── init.pp
└── phpstorm.pp
@cmuench
cmuench / magento_list_available_totals.php
Created March 24, 2012 15:24
Little script to list all configured magento totals.
<?php
require_once 'app/Mage.php';
Mage::app();
$xml = Mage::getConfig()->getNode('global/sales/quote/totals');
$totals = array();
foreach ($xml->children() as $total) {
$totals[] = $total->getName();
@cmuench
cmuench / File.php
Created March 30, 2012 10:46 — forked from colinmollenhour/A-repo-moved.md
Cm_Cache_Backend_File
<?php
/**
* Cm_Cache_Backend_File
*
* The stock Zend_Cache_Backend_File backend has extremely poor performance for
* cleaning by tags making it become unusable as the number of cached items
* increases. This backend make many changes resulting in a huge performance boost,
* especially for tag cleaning.
*
* This cache backend works by indexing tags in files so that tag operations
@cmuench
cmuench / list_db_resources.php
Created July 10, 2012 08:21
List magento db resources
<?php
require_once 'app/Mage.php';
Mage::app();
$xml = Mage::app()->getConfig()->getNode('global/resources');
foreach ($xml->children() as $node) {
echo $node->getName() . PHP_EOL;
}
@cmuench
cmuench / gist:3082029
Created July 10, 2012 08:28
Magento: Save multiple models in one transaction
<?php
// $foo = Mage::getModel('.....
// $bar = Mage::getModel('.....
$transaction = Mage::getModel('core/resource_transaction');
$transaction->addObject($foo);
$transaction->addObject($bar);
$transaction->save(); // runs save on all objects. On error -> rollback
@cmuench
cmuench / gist:3082090
Created July 10, 2012 08:44
Reindex product flat index for a single store view
<?php
require_once 'app/Mage.php';
Mage::app('admin');
$indexer = Mage::getSingleton('catalog/product_flat_indexer');
$indexer->rebuild(22);
@cmuench
cmuench / config.xml
Created September 2, 2012 08:25
Register Own Magento Admin Theme
<?xml version="1.0"?>
<config>
<stores>
<admin>
<design>
<theme>
<default>mytheme</default>
</theme>
</design>
</admin>
<?php
$input = new StringInput('cache:flush');
// without output
$this->getApplication()->run($input, new NullOutput());
// with output
$this->getApplication()->run($input, $output);
@cmuench
cmuench / create_map.php
Created April 5, 2013 13:12
Create map for PHPStorm
<?php
// Init framework
require 'app/Mage.php';
Mage::app();
// Factory methods to search for
$methods = array(
'Mage::helper',
'Mage::getModel',
'Mage::getResourceModel',