Skip to content

Instantly share code, notes, and snippets.

View mschultheiss83's full-sized avatar

Martin Schultheiß mschultheiss83

View GitHub Profile

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".

<?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')
*
...
location ~ .php$ {
...
## Magento 2 Developer mode
fastcgi_param MAGE_MODE "developer";
...
}
...
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;

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

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;

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
# original from http://activecodeline.com/git-ignore-gitignore-file-for-magento-project
# tested with Magento 1.4.0.1
# put it into magento install dir
app/code/community/Phoenix/
app/code/core/
app/design/adminhtml/default/default/
app/design/frontend/base/

Magento SQL Snippets

Clear Temporary Data Tables

TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
<?xml version="1.0"?>
<!-- license -->
<config>
<global>
<!-- global config -->
</global>
<frontend>
<events>
<!-- disble logs -->
<controller_action_predispatch>