Skip to content

Instantly share code, notes, and snippets.

# use this inside lib/Zend to make the version of ZF usable with php 5.6
sed -i "s/'internal_encoding'/'default_charset'/g" ./XmlRpc/Client.php ./Service/Audioscrobbler.php ./Service/Technorati.php ./Locale/Format.php ./Validate/Hostname.php ./Validate/StringLength.php

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
<?php
/**
* Generate modman file from Magento Connect 2.0 package.xml
*
* Usage:
*
* php package2modman.php path/to/package.xml > path/to/modman
*
*/
require_once(__DIR__ . "/../www/app/Mage.php");
@nhp
nhp / customer_export.php
Last active July 30, 2020 11:57
Magento customer migration from one instance to another even with version changes (max tested difference: mageCE 1.5 > 1.9)
<?php
set_time_limit(0);
$pathTo = '../../';
$magentoFilename = $pathTo . 'app/Mage.php';
require_once $magentoFilename;
umask(0);
@nhp
nhp / gist:9166abfee3b7ba2ef6f2
Created July 17, 2014 11:13
Attribute option update model based
public function quickNDirtyUpdateAttributeOptions($row)
{
foreach ($row as $data) {
$this->isAttributeCodeValid($data['attribute_code']);
$id = Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product', $data['attribute_code']);
$attr = Mage::getModel('eav/entity_attribute')->load($id);
//set adminid to have a general and always present identifier for the attribute options
$allOptions = $attr->setStoreId(0)->getSource()->getAllOptions(false);
foreach (Mage::app()->getStores() as $store) {
$stores[$store->getName()] = $store->getId();
@nhp
nhp / local.xml
Created October 30, 2013 08:31
Webfont in magento local.xml layout einbinden
default>
<reference name="root">
<reference name="head">
<action method="addCss"><stylesheet>css/custom.css</stylesheet></action>
<block type="core/text" name="google.font.oswald">
<action method="setText">
<text><![CDATA[<link href='http://fonts.googleapis.com/css?family=Oswald:400,700,300' rel='stylesheet' type='text/css'>]]></text>
</action>
</block>
</reference>
#!/usr/bin/env php
<?php
//
// PHP REPL with initialized Magento environment
//
// Thanks to https://github.com/d11wtq/boris
//
// Drop this script in your $PATH and run it anywhere in a Magento directory tree to start the REPL
//
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;
<?php
/*
To make the cleaning expired carts automatic, override cleanExpiredQuotes with the following
version which will also take care of the old active carts: app/code/core/Mage/Sales/Model/Observer.php
*/
public function cleanExpiredQuotes($schedule)
{
// extending limit
@nhp
nhp / composer.json
Created June 7, 2013 11:02
composer.json
{
"require": {
"connect20/dsdata_nostate": "*",
"therouv/debitpayment": "*",
"connect20/bankpayment": "*",
"connect20/locale_mage_community_de_de": "*",
"magento-hackathon/magento-composer-installer": "*",
"colinmollenhour/cache-backend-redis": "*",
"colinmollenhour/redis-session": "*",
"firegento/germansetup": "*",