Skip to content

Instantly share code, notes, and snippets.

<?php
if ($collection->isLoaded()) {
$collection->getSelect()->reset();
}
<?php
class My_Foo_Block_Thing extends Mage_Core_Block_Template
{
protected $_cacheKey = "your-cache-key";
protected function _construct()
{
$this->addData([
'cache_lifetime'=> false,
@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
$hostname = '127.0.0.1';
$username = 'username';
$password = 'password';
$connection = ftp_connect($hostname);
$login = ftp_login($connection, $username, $password);
@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=""
@ryaan-anthony
ryaan-anthony / observer.php
Created November 6, 2015 19:08
handle various controllers from a single pre-dispatch
<?php
class Observer
{
public function handleControllerActionPredispatch(Varien_Event_Observer $observer)
{
$controllerAction = $observer->getEvent()->getControllerAction();
if ($controllerAction instanceOf Mage_Checkout_OnepageController) {
// currently handling a onepage checkout route
<?php
/**
* @param string
* @param string
* @param Mage_Core_Model_Store
* @throws Exception
*/
function createRedirect($fromUrl, $toUrl, Mage_Core_Model_Store $store)
{
#!/bin/bash
if [ -z $1 ]
then
echo 'Sitemap must be provided as first argument.';exit 2
fi
# Helper function to read xml
read_dom () {
local IFS=\>
@ryaan-anthony
ryaan-anthony / curl.out
Created December 17, 2015 15:20
Using CURL to make SOAP requests with Magento 1.x
$ cat login.xml
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<MAGE:login xmlns:MAGE="http://xxxxxx/api/v2_soap/?wsdl=1">
<MAGE:username>xxxxxx</MAGE:username>
<MAGE:apiKey>xxxxxx</MAGE:apiKey>
</MAGE:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
$ curl --data @login.xml http://xxxxxx/api/v2_soap
<?xml version="1.0"?>
<config>
<placeholders>
<your_modules_holepunch_node>
<block>your_module/your_block</block>
<name>layout.name.for.your.block</name>
<container>Your_Module_Model_Container</container>
<placeholder>PLACEHOLDER_NAME_FOR_YOUR_CONTAINER</placeholder>
</your_modules_holepunch_node>
</placeholders>