Skip to content

Instantly share code, notes, and snippets.

View mschultheiss83's full-sized avatar

Martin Schultheiß mschultheiss83

View GitHub Profile

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
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;

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

server {
set $domain 'yourdomain.com';
server_name $domain;
root /home/$domain/public;
access_log /home/$domain/logs/access.log;
error_log /home/$domain/logs/error.log;
# Cache static files for as long as possible
location ~* \.(?:xml|ogg|mp3|mp4|ogv|svg|svgz|eot|otf|woff|ttf|css|js|jpg|jpeg|gif|png|ico)$ {
try_files $uri =404;
...
location ~ .php$ {
...
## Magento 2 Developer mode
fastcgi_param MAGE_MODE "developer";
...
}
...
<?php
/**
* Input string parser that keeps variable keys in their original state.
*
* Input string keys containing '-','.',' ' are replaced by PHP with parse_str or $_POST
* with '_'. So &I+have+a+space=value becomes array('I_hava_a_space'=>'value')
*
* With InputStrParser->parseCharacterSafe('I+have+a+space=value') becomes
* array('I hava a space'=>'value')
*

Debugging (Resource) Model Instantiation

Follow each step manually and any bugs during (resource) model instantiation will become obvious.

Since many people find model and resource model instantiation to be one of the more challenging things in Magento 1, these are all the steps Magento does to resolve the factory name to the real PHP class name.

To debug, simply follow each step manually until you find a non-match. This works really well in my experience.
Less guessing, more and faster results.

In the examples I use a factory name of "example/thing".

@mschultheiss83
mschultheiss83 / gist:5341888
Created April 9, 2013 00:30 — forked from guipdutra/gist:5341767
git log pretty format
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@mschultheiss83
mschultheiss83 / gist:5341886
Created April 9, 2013 00:29 — forked from guipdutra/gist:5341767
git log pretty format
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit