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
Product loadby attribute:
Array
(
[entity_id] => 5345
[entity_type_id] => 4
[attribute_set_id] => 4
[type_id] => simple
[sku] => WL2309
[has_options] => 0
@amacgregor
amacgregor / clearorders.php
Created December 17, 2012 15:49
What not to have in production
<?php
/**
* @author Dejan Radic <[email protected]>
*/
if (version_compare(phpversion(), '5.2.0', '<')===true) {
echo '<div style="font:12px/1.35em arial, helvetica, sans-serif;"><div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"><h3 style="margin:0; font-size:1.7em; font-weight:normal; text-transform:none; text-align:left; color:#2f2f2f;">Whoops, it looks like you have an invalid PHP version.</h3></div><p>Magento supports PHP 5.2.0 or newer. <a href="http://www.magentocommerce.com/install" target="">Find out</a> how to install</a> Magento using PHP-CGI as a work-around.</p></div>';
exit;
}
@amacgregor
amacgregor / ItemController.php
Created April 3, 2013 22:39
ItemController first example
<?php
class Mdg_Giftregistry_ItemController extends Mage_Core_Controller_Front_Action
{
public function addAction()
{
return $this;
}
public function editAction()
{
@amacgregor
amacgregor / Add.php
Created April 3, 2013 22:57
Skeleton of add to Registry block
<?php
class Mdg_Giftregistry_Block_Add extends Mage_Core_Block_Template
{
}
@amacgregor
amacgregor / Add.php
Created April 3, 2013 23:34
getCustomerRegistryCollection function added to the blokc
<?php
class Mdg_Giftregistry_Block_Add extends Mage_Core_Block_Template
{
public function getCustomerRegistryCollection()
{
$customer = Mage::getSingleton('customer/session')->getCustomer();
if ($customer) {
$collection = Mage::getModel('mdg_giftregistry/entity')->getCollection()
@amacgregor
amacgregor / add_to_registry.phtml
Last active December 15, 2015 18:58
Add to registry template
<?php
$collection = $this->getCustomerRegistryCollection();
?>
<?php if($collection->count() > 0): ?>
<?php $helper = Mage::helper('mdg_giftregistry'); ?>
<form action="<?php echo $this->getUrl('giftregistry/item/add/') ?>" method="post" id="form-validate">
<fieldset>
<select id="registry_id" name="registry_id">
<?php foreach($collection as $registry): ?>
@amacgregor
amacgregor / mdg_giftregistry.xml
Created April 4, 2013 09:13
mdg_giftregistry
<?xml version="1.0"?>
<layout version="0.1.0">
<catalog_product_view translate="label">
<reference name="content">
<reference name="product.info">
<block type="mdg_giftregistry/add" name="registry.add" as="registry_add" template="mdg/add_to_registry.phtml" />
</reference>
</reference>
</catalog_product_view>
</layout>
@amacgregor
amacgregor / view.phtml
Created April 4, 2013 09:23
Add to registry form call
<?php
/**
* Product view template
*
* @see Mage_Catalog_Block_Product_View
* @see Mage_Review_Block_Product_View
*/
?>
<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
@amacgregor
amacgregor / config.xml
Last active December 16, 2015 13:39 — forked from anonymous/config
<?xml version="1.0"?>
<!--
/**
* @category Signifyd
* @package Signifyd_Connect
* @author Alex Manelis
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-->
<config>
@amacgregor
amacgregor / err001.php
Last active December 16, 2015 18:29
Errata 001 Fixed
<?php
$productCollection->addAttributeToFilter('small_image',array('notnull'=>'','neq'=>'no_selection'))
->addAttributeToFilter('thumbnail', array('notnull'=>'','neq'=>'no_selection'))
->addAttributeToFilter('image', array('notnull'=>'','neq'=>'no_selection'));