Skip to content

Instantly share code, notes, and snippets.

View tim-bezhashvyly's full-sized avatar

Tim Bezhashvyly tim-bezhashvyly

View GitHub Profile
@aadmathijssen
aadmathijssen / add-checkout-form-key.sh
Last active October 29, 2019 13:52 — forked from schmengler/add-checkout-form-key.sh
Magento SUPEE-9767 Checkout Form Key Theme Patch
find -L app/design/frontend -name 'shipping.phtml' -or -name 'billing.phtml' -or -name 'shipping_method.phtml' -or -name 'payment.phtml' -or -name 'addresses.phtml' \
| xargs grep -L formkey \
| xargs perl -i -pe 's/<\/form>/<?php echo \$this->getBlockHtml("formkey") ?>\n<\/form>/g'
find -L skin/frontend -name 'opcheckout.js' \
| xargs grep -L form_key \
| xargs perl -i -pe 's/if \(elements\[i\]\.name=='\''payment\[method\]'\''\) \{/if (elements[i].name=='\''payment[method]'\'' || elements[i].name == '\''form_key'\'') {/g'
find -L js -name 'payment.js' \
| xargs grep -L form_key \
@Vinai
Vinai / prime-factors.sh
Created December 13, 2016 18:57
Language or testing frameworks or the lack thereof are no reason not to write tests. All that is needed is a function that calls the function to be checked.
#!/usr/bin/env bash
function assert_array_same {
if [ "${expected[*]}" != "${actual[*]}" ]; then
echo -e "\nFailed $1\nExpected: ${expected[*]}\nActual: ${actual[*]}" && exit 1
else
echo -en "."
fi
}
@Vinai
Vinai / Magento_IntegrationTest_Config.php
Last active October 18, 2016 17:16
Simple Magento 1 bootstrap for PHPUnit.
<?php
class Magento_IntegrationTest_Config extends Mage_Core_Model_Config
{
private $modelTestDoubles = [];
private $resourceModelTestDoubles = [];
public function setModelTestDouble($modelClass, $testDouble)
{
@aleron75
aleron75 / shell_delete_unused_images
Last active October 24, 2023 19:59
Delete no more used Product Images on Magento 1
<?php
require_once 'abstract.php';
class Mage_Shell_CheckImages extends Mage_Shell_Abstract
{
const CATALOG_PRODUCT = '/catalog/product';
const CACHE = '/cache/';
protected function _glob_recursive($pattern, $flags = 0)
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@Schrank
Schrank / Observer.php
Created February 20, 2013 18:23
Check wether a collection should load an attribute
<?php
class Observer {
protected function _collectionShouldLoadWidthAndHeight(Mage_Catalog_Model_Resource_Product_Collection $collection)
{
$reflection = new ReflectionProperty($collection, '_selectAttributes');
$reflection->setAccessible(true);
$value = $reflection->getValue($collection);
return array_key_exists('original_height', $value) || array_key_exists('original_width', $value);
}
}
@bminer
bminer / changeTypeAttr.js
Created August 31, 2012 21:30
Cross-browser solution for changing the 'type' attribute of an `<input/>` tag.
/* x is the <input/> element
type is the type you want to change it to.
jQuery is required and assumed to be the "$" variable */
function changeType(x, type) {
if(x.prop('type') == type)
return x; //That was easy.
try {
return x.prop('type', type); //Stupid IE security will not allow this
} catch(e) {
//Try re-creating the element (yep... this sucks)
@millejano
millejano / Magento Subcategories via a Static Block
Created June 28, 2012 13:00
Magento Subcategories via a Static Block
<?php
/**
* NOTICE OF LICENSE (MIT License)
*
* Copyright (c) 2009, One Eighty Studios Limited
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@brankoajzele
brankoajzele / gist:2781404
Created May 24, 2012 12:56
Programatically create Magento order with tablerate shipping
<?php
require_once 'app/Mage.php';
Mage::app();
$quote = Mage::getModel('sales/quote')
->setStoreId(Mage::app()->getStore('default')->getId());
$product = Mage::getModel('catalog/product')->load(6); /* 6 => Some product ID */
@colinmollenhour
colinmollenhour / cleanCache.php
Created May 17, 2012 00:50
Simplified cache cleaning script for production updates.
<?php
/**
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and
* then use this script to apply updates and refresh the config cache without
* causing a stampede on the config cache.
*
* @author Colin Mollenhour
*/
umask(0);
ini_set('memory_limit','512M');