Skip to content

Instantly share code, notes, and snippets.

View amacgregor's full-sized avatar
:shipit:
Working on Side Projects

Allan MacGregor amacgregor

:shipit:
Working on Side Projects
View GitHub Profile
@amacgregor
amacgregor / err002.php
Last active December 16, 2015 18:29
Errata 02 Code After
<?php
$resource = Mage::getModel('core/resource');
$write = $resource->getConnection('core_write');
$tablename = $resource->getTableName('cataloginventory/stock_item');
$query = "UPDATE {$tablename} SET `is_in_stock` = 1";
$write->query($query);
@amacgregor
amacgregor / err004.php
Created April 28, 2013 20:06
Errata 004 Code After
<?php
$_collection = $this->getCustomerRegistries();
$helper = Mage::helper('mdg_giftregistry');
?>
Server {
Port = 8082
SourceRoot = /srv/www/snuggle.demacmedia.com/public_html
DefaultDocument = index.php
EnableStaticContentCache = 0
EanbleStaticContentFromDisk = true
}
AdminServer {
Port = 8282
Password = admin
Server {
Port = 8080
SourceRoot = /srv/www/clean_ce_1702/public_html/
DefaultDocument = index.php
EnableStaticContentCache = 0
EnableStaticContentFromDisk = true
}
AdminServer {
Port = 8181
Password = admin
@amacgregor
amacgregor / registry_type_table.php
Created August 12, 2013 22:40
Creates the Registry Type tabke
/**
* Create Registry Type Table
*/
$tableName = $installer->getTable('mdg_giftregistry/type');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
$table = $installer->getConnection()
->newTable($installer->getTable('mdg_giftregistry/type'))
->addColumn('type_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
@amacgregor
amacgregor / create_item_registry_table.php
Created August 12, 2013 22:42
Create the Item Registry Table
/**
* Create Registry Item Table
*/
$tableName = $installer->getTable('mdg_giftregistry/item');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
$table = $installer->getConnection()
->newTable($installer->getTable('mdg_giftregistry/item'))
->addColumn('item_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
'identity' => true,
@amacgregor
amacgregor / install-0.1.0.php
Created August 12, 2013 22:43
Full installation script for the mdg_giftregistry
<?php
$installer = $this;
$installer->startSetup();
/**
* Create Registry Type Table
*
@amacgregor
amacgregor / chap4_challenge3_1.php
Created August 13, 2013 01:39
Original actions for the IndexController
<?php
....
public function newPostAction()
{
try {
$data = $this->getRequest()->getParams();
$registry = Mage::getModel('mdg_giftregistry/entity');
$customer = Mage::getSingleton('customer/session')->getCustomer();
@amacgregor
amacgregor / Vagrantfile
Created August 15, 2013 15:26
vagrant config file for hhvm
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "base"
@amacgregor
amacgregor / IndexController.php
Last active December 21, 2015 06:09
_initModel function for the frontend indexController
<?php
...
public function _initModel($param = 'id')
{
$model = Mage::getModel('mdg_giftregistry/entity');
$model->setStoreId($this->getRequest()->getParam('store', 0));
if( $modelId = $this->getRequest()->getParam($param))
{