Skip to content

Instantly share code, notes, and snippets.

View astorm's full-sized avatar

Alana Storm astorm

View GitHub Profile
@astorm
astorm / gist:972291eb28b148a80799
Created July 28, 2014 15:48
Why I Call the Files in app/etc/modules "Declaration Files"
#File: app/code/core/Mage/Core/Model/Config.php    
/**
 * Load declared modules configuration
 *
 * @param   null $mergeConfig depricated
 * @return  Mage_Core_Model_Config
 */

protected function _loadDeclaredModules($mergeConfig = null)

#!/usr/bin/php
<?php
namespace Pulsestorm\Stackexchange\Magento\Noupvotes;
/**
* A simple shell script for returning a list of questions
* with an answer or have answers with no upvotes. Suffers
* from "thrown together for my own use" syndrome, but it
* does the job.
*
* @author Alan Storm http://alanstorm.com
$value = array_key_exists('test', $_COOKIE) ? $_COOKIE['test'] : 0;
$value++;
setcookie('test', $value);
var_dump($value);
session_start();
$value = array_key_exists('test2', $_SESSION) ? $_SESSION['test2'] : 0;
$value = $value ? $value : 0;
$value++;
<?php
//never do this for read, use __construct dependency injection
$r = new ReflectionObject($app);
$prop = $r->getProperty('_objectManager');
$prop->setAccessible(true);
$manager = $prop->getValue($app);
//generates a factory, assuming `Pulsestorm\Helloworld\Test` exists
$factory = $manager->get('Pulsestorm\Helloworld\TestFactory');

The worst one act play ever.

New User:   Hello Magento Site, give me a catalog listing page

Varnish:    Someone wants a page, do I have it cached?  Yes! Since I
            have it cached, I don't need to talk to Magento, I can just sent
            the user this page.

            [Varnish grabs the page]
@astorm
astorm / answer.md
Created August 3, 2015 22:28
Answer to: http://stackoverflow.com/questions/31797607/undefined-variable-get, obnoxious closed because it wasn't in english.

Apologies for the English, but I don't speak or read your language (Russian?). This answer is based on Google translate's version of what you asked.

PHP's super globals ($_GET, $_POST, etc.) are special variables, and it looks like you can't use these variables with PHP's variable variable feature. For example, this works

$foo = ['Hello'];    
$var_name = 'foo';
var_dump($$var_name);

The "variable variable" $$var_name expands as $'foo'/$foo, and the variable dumps correctly.

app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php
app/code/Magento/AdvancedPricingImportExport/Controller/Adminhtml/Export/GetFilter.php
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Place.php
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Redirect.php
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ReturnQuote.php
app/code/Magento/Authorizenet/Controller/Directpost/Payment/ReturnQuote.php
@astorm
astorm / commerce_bug_error
Created April 21, 2011 15:43 — forked from anonymous/commerce_bug_error
Commerce Bug error
Magento 1.4.1.1
URL: .../catalogsearch/result/?q=test
Fatal error: Call to undefined method Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Flat::getEntityType() in /var/www/html/products/app/code/local/[redacted]/Commercebug/Model/Collectorcollections.php on line 36
<?php
#File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
/**
* Generating and validating class file name,
* class and if evrything ok do include if needed and return of class name
*
* @return mixed
*/
protected function _validateControllerClassName($realModule, $controller)
@astorm
astorm / Loader.php
Created December 14, 2011 17:42
Old Magento Loader from an Earlier Alpha
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php