Skip to content

Instantly share code, notes, and snippets.

Avatar

David Alexander davidalexander

View GitHub Profile
View gist:1086455

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@davidalexander
davidalexander / readme.md
Created Jan 4, 2021
Skywire / m2-module-linked-products
View readme.md

m2-module-linked-products

Link products to each other with user configurable types.

Installation

Install via composer

composer require skywire/linkedproducts

@davidalexander
davidalexander / rsync_magento_media.sh
Last active Jan 29, 2020
rsync the media directory from live site to local site. Useful when you need imagery which is (correctly) ignored by version control.
View rsync_magento_media.sh
rsync \
--verbose \
--progress \
--stats \
--compress \
--rsh=/usr/bin/ssh \
--recursive \
--times \
--perms \
--links \
@davidalexander
davidalexander / speedcurveAlert.php
Created Jul 25, 2018
A script to get the commit message and use it as the note to trigger a speedcurve deploy (magento 1)
View speedcurveAlert.php
<?php
class Skywire_Speedcurve_Alert extends Mage_Shell_Abstract
{
const GIT_COMMIT_API = 'https://api.github.com/repos/%s/%s/git/commits/%s';
const SPEEDCURVE_API = 'https://api.speedcurve.com/v1/deploys';
protected $hash;
View magento_logrotate
# /etc/logrotate.d/magento
"/path/to/site/var/log/*.log"
"/path/to/another-site/var/log/*.log" {
compress
copytruncate
daily
missingok
notifempty
olddir archive
@davidalexander
davidalexander / gist:7772193
Created Dec 3, 2013
Magento: Efficiently get a single product attribute from product id
View gist:7772193
<?php
$attribute_value = Mage::getResourceSingleton('catalog/product')->getAttributeRawValue($productId, 'attribute_code', Mage::app()->getStore());
echo $attribute_value;
View My xdebug php config values
xdebug.remote_autostart=true
xdebug.remote_enable=1
xdebug.collect_vars=on
xdebug.collect_params=4
xdebug.show_local_vars=on
xdebug.var_display_max_depth=5
xdebug.show_exception_trace=on
@davidalexander
davidalexander / gist:6937862
Created Oct 11, 2013
Magento - Report for count and revenue of promotions
View gist:6937862
SELECT
sr.`name` as rule_name,
count(*) as total_orders,
SUM(sfo.`total_paid`) as revenue,
sr.`rule_id`,
sfo.`applied_rule_ids`
FROM
`sales_flat_order` sfo,
`salesrule` sr
WHERE
@davidalexander
davidalexander / index.php
Last active Oct 4, 2015
Magento developer subdomains
View index.php
/**
* Set developer mode and display_errors based on subdomain
*/
$staging_subdomains = array(
's1',
's2',
's3',
's4',
's5',
'mac',
@davidalexander
davidalexander / index.php
Created Mar 15, 2012
Thoughts on best way to test subdomain
View index.php
<?php
/**
* how best to turn on errors for staging subdomains
*
* as this is in the index.php, performance is important,
* although technically the page will be cached
*/
// 1. preg_match
if (preg_match('/^s1\.|^s2\.|^s3\.|^s4\.|^s5\.|^mac\.|^local\.|^mac-upgrade\./', $_SERVER['HTTP_HOST'])) {