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 / fullquery.diff
Created January 31, 2014 09:36
Show full query in Magento stack trace
diff --git a/lib/Zend/Db/Statement/Pdo.php b/lib/Zend/Db/Statement/Pdo.php
index cd0a947..b116e3d 100644
--- a/lib/Zend/Db/Statement/Pdo.php
+++ b/lib/Zend/Db/Statement/Pdo.php
@@ -231,7 +231,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
}
} catch (PDOException $e) {
#require_once 'Zend/Db/Statement/Exception.php';
- throw new Zend_Db_Statement_Exception($e->getMessage(), (int) $e->getCode(), $e);
+ throw new Zend_Db_Statement_Exception($e->getMessage() . PHP_EOL . $this->_stmt->queryString, (int) $e->getCode(), $e);
@peterjaap
peterjaap / placeInCategoryBasedOnAttributeset.sql
Last active August 29, 2015 13:56
Place products in a specified category based on attribute set
SELECT @cat_id := entity_id FROM catalog_category_flat_store_1 WHERE url_path = 'merken/makita';
SELECT @attr_set_id := attribute_set_id FROM eav_attribute_set WHERE attribute_set_name = 'Makita';
INSERT IGNORE catalog_category_product (category_id,product_id) SELECT @cat_id, entity_id FROM catalog_product_entity WHERE attribute_set_id = @attr_set_id;
@peterjaap
peterjaap / getArrayToObjectResults.php
Created March 5, 2014 13:54
This function creates a multi-dimensional Varien_Object by inputting a multi-dimensional array
<?php
public function getArrayToObjectResults($array) {
$obj = new Varien_Object();
foreach($array as $k => $v) {
if(strlen($k)) {
if(is_array($v)) {
$obj->{$k} = $this->getArrayToObjectResults($v);
} elseif ($k !== '') {
$obj->{$k} = $v;
}
@peterjaap
peterjaap / separate_db.php
Last active August 29, 2015 14:01
Magento separate db connection
<?php
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host'=> '127.0.0.1',
'username' => 'webuser',
'password' => 'xxxxxxxx',
'dbname'=> 'test',
'profiler' => true,
));
@peterjaap
peterjaap / abandonedcart_stock_check.php
Last active August 29, 2015 14:01
Ebizmarts_AbandonedCart doesn't check whether a product that will be sent in an Abandoned Cart email is still available. This piece of code checks whether the product still exists, is enabled and has stock available (if stock is managed). If any of these 3 do not comply, the product is removed from the quote. Finally, we check whether there are …
<?php
/* Place this on line 117, right after foreach($collection as $quote) in app/code/community/Ebizmarts/AbandonedCart/Model/Cron.php */
foreach($quote->getAllVisibleItems() as $item) {
$removeFromQuote = false;
$product = Mage::getModel('catalog/product')->load($item->getProductId());
if(!$product || $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED)
{
Mage::log('AbandonedCart; ' . $product->getSku() .' is no longer present or enabled; remove from quote ' . $quote->getId() . ' for email',null,'Ebizmarts_AbandonedCart.log');
@peterjaap
peterjaap / analyzeVoys.php
Last active August 29, 2015 14:06
Analyze Voys CDRS file (downloadable from mijn.voys.nl)
<?php
if(count($argv)==1) {
echo <<< EOT
Usagae; {$_SERVER['PHP_SELF']} {filename} {from} {to} {showUpper}
Filename defaults to cdrs.csv
From defaults to today
To defaults to From plus 1 year
ShowUpper only shows top X callers (defaults to 25)
Example; {$_SERVER['PHP_SELF']} cdrs.csv 01-01-2014 01-07-2014
@peterjaap
peterjaap / .zshrc
Last active August 29, 2015 14:06
.zshrc
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Themes; look in ~/.oh-my-zsh/themes/
ZSH_THEME="robbyrussell"
plugins=(git)
# Oh my ZSH
source $ZSH/oh-my-zsh.sh
. ~/.rupa-z/z.sh
@peterjaap
peterjaap / createGmailFiltersCodebase.php
Last active August 29, 2015 14:06
Create Gmail forwarders for Codebase tickets
<?php
/*
This little script creates an XML file for you to import in your Gmail account.
It creates forwarders to automatically create tickets in Codebase with an
easy to remember emailformat like tickets-<projectname>@company.com.
For more information see http://support.codebasehq.com/articles/tickets/submitting-a-ticket-via-e-mail
and http://gmailblog.blogspot.nl/2009/03/new-in-labs-filter-importexport.html
@peterjaap
peterjaap / ActiveAnts patch.patch
Created December 2, 2014 10:50
ActiveAnts patch images over HTTP or HTTPS
From 3d350f20228960007ac1c38a59fc9734c4b8643d Mon Sep 17 00:00:00 2001
From: Peter Jaap Blaakmeer <peterjaap@elgentos.nl>
Date: Tue, 2 Dec 2014 11:23:15 +0100
Subject: [PATCH 1/2] Set secure true to check for is true or not
---
.../base/default/template/activeants/checkout/cart/shipping.phtml | 2 +-
.../activeants/checkout/onepage/shipping_method/available.phtml | 4 ++--
.../activeants/checkout/onestepcheckout/shipping_method.phtml | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
@peterjaap
peterjaap / ghostinspector.rb
Last active August 29, 2015 14:18
Capistrano Ghostinspector function
require 'json'
require 'rubygems'
require 'curb'
namespace :ghostinspector do
desc 'Run Ghostinspector test suite'
task :testsuite do
version = "v1"
apikey = "PLACE_API_KEY_HERE"
testsuite = "PLACE_TESTSUITE_HASH_HERE"