Skip to content

Instantly share code, notes, and snippets.

View mschultheiss83's full-sized avatar

Martin Schultheiß mschultheiss83

View GitHub Profile
delimiter ;;
drop procedure if exists build_catalog;;
create procedure build_catalog(IN categories INT, IN products INT)
begin
SET @category_count = 1;
SET @CATNAMEPREFIX = "Category ";
SET @CATURLKEYPREFIX = "cat-";
SET @CATURLPATHPREFIX = "catpath-";
SET @ROOTCATEGORY = 2;
SET @INCLUDEINMENU = 1;

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
# original from http://activecodeline.com/git-ignore-gitignore-file-for-magento-project
# tested with Magento 1.4.0.1
# put it into magento install dir
app/code/community/Phoenix/
app/code/core/
app/design/adminhtml/default/default/
app/design/frontend/base/
@mschultheiss83
mschultheiss83 / time.php
Created September 5, 2013 14:23
Calculate script execution time (PHP class)
<?php
/**
* http://codeaid.net/php/calculate-script-execution-time-(php-class)
* Created by tripuls.
* User: m.schultheiss
* Date: 05.09.13
* Time: 16:20
*/
class Timer
@mschultheiss83
mschultheiss83 / clFile.php
Last active December 29, 2015 10:19
Dateinamen bereinigen clean up filenames
<?php
/**
* äöüß und co
*/
function cleanUpFilename($val){
// whitespace durch Unterstrich ersetzen
$new = preg_replace('=(\s+)=', '_', $val);
// Liste aller Umlaute
$map = array(
'ä' => 'ae',
@mschultheiss83
mschultheiss83 / .gitignore
Last active December 29, 2015 10:19
Magento gitignore
# configs
/app/etc/local.xml
/errors/local.xml
/app/etc/use_cache.ser
# downloader
/downloader/.cache
/downloader/cache.cfg
/downloader/connect.cfg

Magento SQL Snippets

Clear Temporary Data Tables

TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
<?xml version="1.0"?>
<!-- license -->
<config>
<global>
<!-- global config -->
</global>
<frontend>
<events>
<!-- disble logs -->
<controller_action_predispatch>
@mschultheiss83
mschultheiss83 / gist:9a35b077da256d0d8606
Last active August 29, 2015 14:01
Magento - loadMedialGallery by Product Id and Store Id
<?php
$backend = Mage::getResourceModel('catalog/product_attribute_backend_media');
$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'media_gallery');
$container = new Varien_Object(array(
'attribute' => new Varien_Object(array('id' => $attributeId))
));
$product = new Varien_Object(array(
'id' => 519,