Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
ScreamingDev / RandomDummy.php
Last active December 18, 2015 05:49
Why does this not get random products?
<?php
include 'app/Mage.php';
Mage::app('default');
/* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
$collection = Mage::getModel('catalog/product')->getCollection();
var_dump($collection->getLoadedIds()); // array()
@ScreamingDev
ScreamingDev / enable_shop_view_image.sql
Last active December 21, 2015 20:59
Magento: First image as Shop Image
# Find out the id to attribute_code "image" (here: 85)
# Find out the according entity_type_id (here: 4)
INSERT INTO catalog_product_entity_varchar (
entity_type_id,
attribute_id,
entity_id,
value
) (
SELECT
@ScreamingDev
ScreamingDev / example.php
Last active December 21, 2015 23:18
get user timeline in twitter
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . 'twitter.php';
$t = new twitter();
// https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
$responseArray = $t->gimme(
'1.1/statuses/user_timeline',
array(
@ScreamingDev
ScreamingDev / playground.php
Created September 1, 2013 15:50
You never find the real problem
<?php
class EventHandler {
public static function preString() {
// imagine: echo (new Unknown());
throw new Exception('something went wrong');
}
}
class OhSnap {
@ScreamingDev
ScreamingDev / Adminhtml.php
Last active December 22, 2015 14:18
Magento UnitTest Adminhtml does not work
<?php
abstract class LeMike_DevMode_Test_Adminhtml extends EcomDev_PHPUnit_Test_Case_Controller
{
const FAKE_USER_ID = 42;
public function setUp()
{
$this->_fakeLogin();
@ScreamingDev
ScreamingDev / Cache.php
Last active December 22, 2015 20:29
Wohoo. Templates and Cache :)
<?php
class Cache {
protected $_scope;
public function __construct($scope = null, $lifetime = 3600) {
if (null === $scope) $scope = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'mikeCache_' . md5(__FILE__) . DIRECTORY_SEPARATOR;
if (!is_dir($scope)) mkdir($scope, 0777, true);
@ScreamingDev
ScreamingDev / Bad.xml
Last active December 23, 2015 01:49
Me vs Magento
<reference name="left">
<block type="lemike_devmode/core_tabs" name="lemike.devmode.core">
<block type="lemike_devmode/core_php" name="lemike_devmode_core_php" template="lemike/devmode/core/resource.phtml"/>
<action method="addTab"><name>core_php</name><block>lemike_devmode_core_php</block></action>
</block>
</reference>
@ScreamingDev
ScreamingDev / FooTest.php
Created September 15, 2013 06:42
Evil eval
function testMike()
{
// mock Mage_Catalog_Model_Product::save for throwing errors
$alias = 'catalog/product';
$cookieMock = $this->getMock($alias, array('save'));
$cookieMock->expects($this->exactly(2))->method('save')->will(
$this->returnCallback(function () {
throw Exception();
})
);
@ScreamingDev
ScreamingDev / README.md
Last active December 23, 2015 03:29
LeMike_DevMode

LeMike_DevMode

An extension to help you develop beautiful Magento Stores.

  • Secured by restricted IPs
  • Redirect Email or show em directly in browser
  • Rerun setups for extensions from backend
  • See all rewrites
  • Login every customer Account with Master Password
  • See all Events, change config or quick translate via URL
@ScreamingDev
ScreamingDev / gist:6612968
Created September 18, 2013 18:00
l = log, s =status, master-v0.4 is A, master-v0.3.2 is B
git merge v0.3.1
git diff v0.3.1
git l
git l HEAD
git l ..HEAD
git checkout master-v0.4
git s
git l
git checkout -B master-v0.3.2
git checkout master-v0.4