Skip to content

Instantly share code, notes, and snippets.

View peterjaap's full-sized avatar

Peter Jaap Blaakmeer peterjaap

  • elgentos ecommerce solutions / Blaakmeer Webdevelopment
  • Groningen, the Netherlands
View GitHub Profile
@peterjaap
peterjaap / diskspace.pl
Created May 13, 2013 14:14
diskspace.pl
#!/usr/bin/perl -w
# Script to check free diskspace and email notifications. Change the email and alert levels and you should be good to go.
# Script PJ Blaakmeer - www.blaakmeer.com
use strict;
# Alert levels Warning and Critical - Below what percent level of free disk space do you want an alert?
my $alert1 = 10; #Warning level free space below 30%
my $alert2 = 5; #Critical level free space below 10%
# Put the email address to notify here
@peterjaap
peterjaap / Enterprise version check.php
Created May 16, 2013 12:25
Check for enterprise & version
<?php
$enterprise = Mage::getConfig()->getNode('modules/Enterprise_PageCache/active');
$checkForVersion = ($enterprise ? '1.12' : '1.7.0.0');
if(version_compare(Mage::getVersion(), $checkForVersion, '<')) {
$this->setTemplate('blockip/sales_order_view_info_16xx.phtml');
} else {
$this->setTemplate('blockip/sales_order_view_info_17xx.phtml');
}
@peterjaap
peterjaap / noindex.xml
Created June 4, 2013 08:44
NOINDEX,NOFOLLOW on search catalog result pages and review pages
<catalogsearch_result_index translate="label">
<reference name="head">
<action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
</reference>
</catalogsearch_result_index>
<catalogsearch_advanced_index translate="label">
<reference name="head">
<action method="setRobots"><value>NOINDEX,NOFOLLOW</value></action>
</reference>
</catalogsearch_advanced_index>
@peterjaap
peterjaap / fireEvent.php
Created June 14, 2013 08:16
Fire a Magento event from CLI
<?php
require 'app/Mage.php';
error_reporting(E_ALL | E_STRICT);
ini_set('html_errors', 1);
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
$orderId = $_GET['order_id'];
@peterjaap
peterjaap / convertAttribute.sql
Created July 3, 2013 08:09
Convert select attribute to multiselect attribute SQL -- replace 'ATTRIBUTE_CODE' with your attribute code.
SELECT @ATTRIBUTE_ID := attribute_id FROM eav_attribute WHERE attribute_code = 'ATTRIBUTE_CODE';
UPDATE eav_attribute SET backend_model = 'eav/entity_attribute_backend_array', backend_type = 'varchar', frontend_input = 'multiselect' WHERE attribute_id = @ATTRIBUTE_ID;
INSERT INTO catalog_product_entity_varchar (entity_type_id, attribute_id, store_id, entity_id, value) SELECT entity_type_id, attribute_id, store_id, entity_id, value FROM catalog_product_entity_int WHERE attribute_id = @ATTRIBUTE_ID;
DELETE FROM catalog_product_entity_int WHERE attribute_id = @ATTRIBUTE_ID;
@peterjaap
peterjaap / importCustomers.php
Created July 9, 2013 09:05
Import customers into Magento
<?
// Preliminary work
error_reporting(E_ALL);
$start = microtime(true);
require 'app/Mage.php';
ini_set('default_socket_timeout',48000);
$resource = Mage::getModel('core/resource');
@peterjaap
peterjaap / createTaxRules.php
Created August 9, 2013 07:47
Generate tax rules for Magento
<?php
chdir(dirname(__FILE__));
require_once '../app/Mage.php';
Mage::app();
umask(0);
require_once 'countries.php'; // import lists with all countries
// UK Island shipping rates; http://www.crearegroup-ecommerce.co.uk/blog/magento-advice/shipping-rates-to-the-uk-islands.php
@peterjaap
peterjaap / countries.php
Created August 9, 2013 07:48
List with two letter ISO country codes
<?php
$worldString = "AF - Afghanistan
AL - Albania
DZ - Algeria
AS - American Samoa
AD - Andorra
AO - Angola
AI - Anguilla
AQ - Antarctica
@peterjaap
peterjaap / Magento generated events
Created October 14, 2013 09:44
Magento generated events; a number of models use automatically generated events through prefixes. This is a (non-exhaustive) list of a number of those events, combined with _save_before, _save_after, _save_commit_after, _delete_before, _delete_after, _delete_commit_after, _load_before & _load_after.
tag_save_after
admin_roles_save_after
admin_user_save_after
review_save_after
catalogsearch_query_save_after
sales_order_save_after
sales_quote_address_save_after
sales_quote_payment_save_after
sales_quote_item_save_after
sales_quote_save_after
@peterjaap
peterjaap / dumpCategories.php
Created October 15, 2013 16:03
Dump categories to tabbed CSV file
<?php
chdir(dirname(__FILE__));
require_once '../app/Mage.php';
@$app = Mage::app($argv[1]);
$catalogId = $app->getStore()->getRootCategoryId();
$category = Mage::getModel ('catalog/category');