Skip to content

Instantly share code, notes, and snippets.

View MagePsycho's full-sized avatar

magepsycho MagePsycho

View GitHub Profile
@matthewhaworth
matthewhaworth / gist:bfc300ecb5a75618d0d5
Last active January 1, 2016 06:09
Magento Install Script
#!/bin/sh
DEFAULT_MAGENTO_VERSION=1.7.0.2
DEFAULT_MAGE_URL="http://127.0.0.1/"
if [ -z $1 ] # Magento version
then
read -p "Choose Magento version ($DEFAULT_MAGENTO_VERSION): " MAGENTO_VERSION
if [ -z "$MAGENTO_VERSION" ]
then
@MagePsycho
MagePsycho / M2 acl.xml
Created February 13, 2016 14:16 — forked from Vinai/M2 acl.xml
My current Magento 2 PHPStorm File Templates (Feb 2016)
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
</resource>
</resources>
</acl>
</config>
@benmarks
benmarks / workbench.php
Last active April 5, 2016 15:07
Magento workbench script with full error output.
<?php
/**
* Working with Magento outside of the normal routing dispatch
* flow of Mage::run()? Mage::app(); is the way to go. This
* workbench script can be a quick way to check on various
* parts of the app, including configuration, which can be
* handy when verifying custom modules.
*/
//set some PHP params for ease of debugging
ini_set('display_errors',true);

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@tegansnyder
tegansnyder / truncate_url_rewrites.sql
Created October 6, 2014 18:01
Truncate URL Rewrites Magento
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `core_url_rewrite`;
TRUNCATE TABLE `enterprise_catalog_category_rewrite`;
TRUNCATE TABLE `enterprise_catalog_product_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite_category_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_product_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect`;
<?php
var_dump(gaSendRefund('2642236223'));
function gaSendRefund($transaction_id)
{
$url = 'https://www.google-analytics.com/collect';
$tid = 'UA-XXXXXXX-X';
$params = http_build_query(
array(
@tegansnyder
tegansnyder / MageStocker.sh
Last active June 7, 2017 11:14
MageStocker - Convert your Magento to stock disabling all extensions and your theme. Allows you to switch it back when you are done testing brining your theme and extensions back to life.
#! /bin/bash
if [ "$#" == "0" ]; then
echo
echo "Sorry cant run!"
echo "No arguments provided. Please pass this script agruments in the following format:"
echo "./magestocker.sh magento_root theme_base current_theme_name"
echo "example: "
echo "./magestocker.sh /var/www/magento default mytheme"
echo "another example:"
@vmasciotta
vmasciotta / sandbox.php
Created April 5, 2016 00:27
Magento2 Sandbox
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//echo "hello world";
try {
require __DIR__ . '/app/bootstrap.php';
@grafikchaos
grafikchaos / Magento - Add Custom Structure Blocks.md
Last active August 18, 2017 10:57
HowTo: Add Custom Structural Blocks to a Layout

Overview

Recently had a client that wanted to customize the layout for a category landing page so that the category's title and description would be displayed above the layered navigation and product grid — essentially creating a full-width section above the left sidebar and main content areas.

NOTE: For reference, this is based off the blog post from Collaboration133.com's Magento - Add Custom Structural Block Reference.

Custom Module (My_LayoutMods)

I created a custom module to help organize and identify that there are some custom modifications to layout templates. Not saying you have to, but it may be easier for other's (or your future self) to recognize and find what customizations were done (and hopefully why).

@hn-support
hn-support / curl_speedtest.sh
Last active October 9, 2017 12:49
Test urls using curl
#!/bin/bash
# This script is a very basic curl utility to analyze urls.
# To use it, download the file, make it executable, and run:
# ./curl_speedtest.sh https://www.byte.nl
URL="$1"
if [ "x${URL}" == "x" ] || [[ ! "${URL}" =~ "http" ]] ; then
echo "Usage: $0 <url>"
exit 1