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 / sandbox_spcustomoptions.php
Created August 11, 2011 18:40
Get Simple product custom options
<?php
//Assuming your product is already loaded
$allOptions = $product->getProductOptions();
foreach($allOptions as $option){
echo $option['label'] . ' - ' $option['value']
}
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app();
//Test Variables
$item['sku'] = 'Avent-Soothie-AD-SCF190/01';
$item['qty'] = 2;
$orderIncrementId = '100003301';
@amacgregor
amacgregor / crontab
Created September 20, 2011 13:37
crontab
#
# Cronjobs for amssusa
#
10 05 * * * php /srv/www/amssusa.com/public_html/shell/indexer.php reindexall
10 05 * * * php /srv/www/amssusa.com/public_html/cron.php
#
# Cronjobs for combatoptical
#
40 05 * * * php /srv/www/combatoptical.com/public_html/shell/indexer.php reindexall
40 05 * * * php /srv/www/combatoptical.com/public_html/cron.php
@amacgregor
amacgregor / api.php
Created September 21, 2011 15:57
OrderEdit APi
<?php
/**
* Edit Order Items.
*
* @param $orderIncrementId
* @param $orderItems
* @param $comment
* @return string
*/
<?php
/**
* Customerreviewimport.php
* CommerceExtensions @ InterSEC Solutions LLC.
*
* NOTICE OF LICENSE
*
* This source file is subject to the EULA
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
@amacgregor
amacgregor / Observer.php
Created October 13, 2011 16:35
checkout_cart_update_items_before
<?php
public function checkout_cart_update_items_before($observer)
{
$event = $observer->getEvent();
$products = $event->getInfo();
$customer = Mage::getSingleton('customer/session');
$items = $observer->getCart()->getQuote();
foreach($products as $key => $value){
$product = $items->getItemById($key);
@amacgregor
amacgregor / sandbox.php
Created October 21, 2011 15:16
Delete Product Custom options
<?php
/**
* Created by JetBrains PhpStorm.
* User: amacgregor
* Date: 10/21/11
* Time: 12:38 PM
* To change this template use File | Settings | File Templates.
*/
require_once 'app/Mage.php';
@amacgregor
amacgregor / mageavcat.php
Created October 25, 2011 00:45 — forked from anonymous/mageavcat
Magento EAV Attribute for Category
INSERT INTO `eav_attribute` VALUES(132, 3, 'include_in_left_menu', NULL, NULL, 'int', NULL, NULL, 'select', 'Include in Left Navigation Menu', NULL, 'eav/entity_attribute_source_boolean', 0, 0, '1', 0, NULL);
<?php
$parentid = 3; //Parent category ID
$parentCat = Mage::getModel('catalog/category')->load($parentid);
$childCategories = explode(',',$parentCat->getChildren()); //Child category IDs separated by commas
?>
@amacgregor
amacgregor / sites.rb
Created October 30, 2011 15:48
Controller
Crow.controllers :sites do
get :index do
@sites = Site.all(:order => 'name')
render 'sites/index'
end
get :show, :with => :id do
@site = Site.get(params[:id])
render 'sites/show'
@amacgregor
amacgregor / rubyrep error
Created June 5, 2012 14:14
rubyrep error
rubyrep --verbose scan -c testconf in ~
/home/mbertulli/.rvm/gems/ruby-1.9.2-head/gems/rubyrep-1.2.0/lib/rubyrep/table_spec_resolver.rb:91: warning: encoding option is ignored - U
Exception caught: Mysql::Error: query: not connected: SHOW TABLES
/home/mbertulli/.rvm/gems/ruby-1.9.2-head/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
/home/mbertulli/.rvm/gems/ruby-1.9.2-head/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `block in execute'
/home/mbertulli/.rvm/gems/ruby-1.9.2-head/gems/activerecord-3.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/home/mbertulli/.rvm/gems/ruby-1.9.2-head/gems/activesupport-3.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/mbertulli/.rvm/gems/ruby-1.9.2-head/gems/activerecord-3.2.5/lib/active_record