Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
ryaan-anthony / magento-backup-db.sh
Last active November 6, 2015 04:35
Backup Magento EE 1.14.2.2 DB without production data.
#!/bin/bash
################################################################################
# FUNCTIONS
################################################################################
# 1. Check required system tools
_check_installed_tools() {
local missed=""
<?php
$hostname = '127.0.0.1';
$username = 'username';
$password = 'password';
$connection = ftp_connect($hostname);
$login = ftp_login($connection, $username, $password);
@ryaan-anthony
ryaan-anthony / test.sql
Created September 20, 2015 16:33
Mysql test table
-- MySQL dump 10.13 Distrib 5.6.24, for osx10.8 (x86_64)
--
-- Host: localhost Database: phpci
-- ------------------------------------------------------
-- Server version 5.6.24
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
<?php
class My_Foo_Block_Thing extends Mage_Core_Block_Template
{
protected $_cacheKey = "your-cache-key";
protected function _construct()
{
$this->addData([
'cache_lifetime'=> false,
<?php
if ($collection->isLoaded()) {
$collection->getSelect()->reset();
}
<?php
class X
{
const X = 'x';
static function foo()
{
@ryaan-anthony
ryaan-anthony / clean.icls
Created July 8, 2015 13:33
Clean PHPStorm Theme
<scheme name="Clean" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.1" />
<option name="EDITOR_FONT_SIZE" value="13" />
<option name="EDITOR_FONT_NAME" value="Courier New" />
<colors>
<option name="CARET_ROW_COLOR" value="" />
<option name="LINE_NUMBERS_COLOR" value="808080" />
</colors>
<attributes>
<option name="BAD_CHARACTER">
<?php
// Set product positions within a selected category
$cat_id = CATEGORY_ID;
$category = Mage::getModel('catalog/category')->load($cat_id);
$cat_api = new Mage_Catalog_Model_Category_Api;

Application initialization My video "Under the hood of Magento": http://www.youtube.com/watch?v=M10RR9acNE8 (watch in 1080p)

Front Controller These articles both cover in greater depth how the Front controller is initiated and how routers are selected. http://www.andreiboar.com/magento/magento-front-controller/ http://blog.belvg.com/magento-front-controller-pattern.html

URL rewrites These articles describe how url paths are formatted, where theyre located, and how theyre used by routers. As well as ... dun dun dunnn .. how the catalog url rewrite indexer works.

@ryaan-anthony
ryaan-anthony / complete.php
Created June 1, 2015 17:44
Set magento orders to complete.
<?php
require_once 'app/Mage.php';
$app = Mage::app();
Mage::register('isSecureArea', true);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$order = Mage::getModel('sales/order')->loadByIncrementId('100000266');
$order->setData('state', 'complete');
$order->setStatus('complete');