Create documentation for your projects. Like so:
- Up/Down - Previous/Next Gist
- Ctrl+e - Edit a selected Gist
- Ctrl+s - Save Gist
<?php | |
// I almost never use $installer = $this; instead I prefer to use the following | |
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup'); | |
// This is just an example of instantiating the setup class in the script. Of | |
// course I choose the appropriate setup class and resource on a case by case basis. | |
// That way it is very visible what setup class is being used. It can also be | |
// switched within a single setup script, for example to add attributes to |
<?php | |
namespace Random\Example; | |
spl_autoload_register(function($class) { | |
echo "Autoload triggered for class $class\n"; | |
}); | |
echo "Importing class with use upcoming...\n"; | |
use Some\Example\Nonexistant\Class\Which\Will\Not\Trigger\The\Autoloader; |
<?php | |
$groupId = 1; | |
Mage::getResourceModel('customer/customer_collection') | |
->addAttributeToFilter('group_id', $groupId) | |
->setDataToAll('customer_activated', 1) | |
->save(); |
<?php | |
require('htdocs/app/Mage.php'); | |
umask(0); | |
Mage::setIsDeveloperMode(true); | |
Mage::app(); | |
$attributeCode = 'description'; // any attribute code | |
// load model without only static attribute values |
<?php | |
/** | |
* Simple Magento integration test PHPUnit bootstrap | |
*/ | |
chdir(__DIR__ . '/../..'); | |
$mageFile = 'htdocs/app/Mage.php'; | |
umask(0); |
<?php | |
umask(0); | |
ini_set('memory_limit','512M'); | |
set_time_limit(0); | |
if(file_exists('app/Mage.php')) require 'app/Mage.php'; | |
else require '../../app/Mage.php'; | |
// Init without cache so we get a fresh version | |
Mage::app('admin','store', array('global_ban_use_cache' => TRUE)); |
<?php | |
class Training_OrderIntegrationClient_Model_Client | |
{ | |
protected $_socket; | |
/** | |
* Workaround to make class testable | |
* |
$product->setData('group_price', array( | |
array( | |
'website_id' => 0, | |
'cust_group' => $customerGroupId, | |
'price' => 19.99 | |
) | |
)); |
#!/usr/bin/env php | |
<?php | |
// | |
// PHP REPL with initialized Magento environment | |
// | |
// Thanks to https://github.com/d11wtq/boris | |
// | |
// Drop this script in your $PATH and run it anywhere in a Magento directory tree to start the REPL | |
// |