Skip to content

Instantly share code, notes, and snippets.

View steverobbins's full-sized avatar

Steve Robbins steverobbins

View GitHub Profile
<?php
$code = 'color';
$opts = Mage::getSingleton('eav/config')
->getAttribute('catalog_product', $code)
->getSource()
->getAllOptions(false);
foreach($opts as $opt) {
@steverobbins
steverobbins / magento-fetch-media.php
Last active May 10, 2017 10:09
Download product media images to your local Magento store without rsync/ftp.
<?php
$range = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9), array('_'));
foreach ($range as $a) foreach ($range as $b) mkdir("$a/$b", 0777, true);
$db = new PDO('mysql:127.0.0.1;dbname=magento', 'root', 'root');
//$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$result = $db->query('select distinct value from catalog_product_entity_media_gallery');
[xdebug]
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.profiler_enable_trigger=1
zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
@steverobbins
steverobbins / Paypal.php
Last active April 22, 2024 12:18
PayPal API Requests
<?php
class Paypal
{
/**
* API Version
*/
const VERSION = 51.0;
/**
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""
<?php
final class Mage
{
// ...
public static function dispatchEvent($name, array $data = array())
{
$e = new Exception();
Mage::log(
$name . ': ' . implode(', ', array_keys($data)) . "\n"
Get-Content dump.sql | Foreach-Object { $_ -replace 'DEFINER(.*)`magento-dbuser`@`localhost`','DEFINER$1`different-user`@`different-host`' } | Set-Content new.sql
<?php
include 'app/Mage.php';
Mage::app('admin', 'store');
$password = substr(md5('Password' . time()), 0, 16);
$user = Mage::getModel("admin/user")
->setData(array(
'username' => 'steve',
SET @DATABASE = 'prod';
SELECT CONCAT(table_schema, '.', table_name),
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
WHERE `information_schema`.TABLES.table_schema = @DATABASE
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""