Create documentation for your projects. Like so:
- Up/Down - Previous/Next Gist
- Ctrl+e - Edit a selected Gist
- Ctrl+s - Save Gist
$product->setData('group_price', array( | |
array( | |
'website_id' => 0, | |
'cust_group' => $customerGroupId, | |
'price' => 19.99 | |
) | |
)); |
<?php | |
class Training_OrderIntegrationClient_Model_Client | |
{ | |
protected $_socket; | |
/** | |
* Workaround to make class testable | |
* |
<?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 | |
/** | |
* Simple Magento integration test PHPUnit bootstrap | |
*/ | |
chdir(__DIR__ . '/../..'); | |
$mageFile = 'htdocs/app/Mage.php'; | |
umask(0); |
<?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 | |
$groupId = 1; | |
Mage::getResourceModel('customer/customer_collection') | |
->addAttributeToFilter('group_id', $groupId) | |
->setDataToAll('customer_activated', 1) | |
->save(); |
<?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 | |
// 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 |
# I want to change the configured sample data name for a given magento package. | |
# | |
# (Alternatively I would like to change the source URL for a sample data package.) | |
# | |
# The following does not work as I intend it to. | |
# It adds a new record to the $this->commandConfig['magento-packages'] | |
# array instead of overwriting the extra sample-data value. | |
# | |
# Can this be done? |