Skip to content

Instantly share code, notes, and snippets.

View mschultheiss83's full-sized avatar

Martin Schultheiß mschultheiss83

View GitHub Profile
<?php
ini_set('display_errors', 1);
ini_set('log_errors', 1);
error_reporting(E_ALL);
require 'app/Mage.php';
Mage::app('admin', 'store');
/* @var $customers Mage_Customer_Model_Resource_Customer_Collection */
$customers = Mage::getResourceModel('customer/customer_collection');
$customers->addAttributeToSelect('*');
$customers->setPageSize((isset($argv[1]) && is_numeric($argv[1]))?$argv[1]:2000);
#!/bin/bash
LOG=var/log/del_unused_img.log
function search_db() {
COUNT=$(mysql -uYOURUSER -pYOURPASSWORD YOURDB --execute="SELECT count(*) FROM catalog_product_entity_media_gallery WHERE value = \"$1\"")
echo $(echo ${COUNT} | cut -d" " -f2)
}
echo "Start: "\n >> ${LOG}
echo $(date) >> ${LOG}
@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,
<?xml version="1.0"?>
<!-- license -->
<config>
<global>
<!-- global config -->
</global>
<frontend>
<events>
<!-- disble logs -->
<controller_action_predispatch>

Magento SQL Snippets

Clear Temporary Data Tables

TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
@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
@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 / 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
# 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/