Skip to content

Instantly share code, notes, and snippets.

View wsagen's full-sized avatar

Genevieve Eddison wsagen

View GitHub Profile
@wsagen
wsagen / dependent Magento configuration
Last active January 3, 2016 11:29
Dependent configuration field in Magento - show a field, dependent on value in another field
<depends>
<dependent_field_name>value_we_are_looking_for</dependent_field_name>
</depends>
@wsagen
wsagen / override javascript object function
Last active January 4, 2016 21:29
Override prototype javascript object or function
Packaging.prototype.sendCreateLabelRequest = Packaging.prototype.sendCreateLabelRequest.wrap(function(parentMethod){
//replace the original method here with your own stuff
console.log('we have overridden their function');
parentMethod();
});
@wsagen
wsagen / Stop controller processing
Last active March 22, 2017 19:41
Stop controller action via predispatch observer
$request = Mage::app()->getRequest();
$action = $request->getActionName();
Mage::app()->getFrontController()->getAction()->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
@wsagen
wsagen / redirect controller
Created January 29, 2014 05:00
Redirect controller action (e.g. within observer predispatch)
public function yourMethod($observer)
{
if ($condition) {
$request = Mage::app()->getRequest();
$request->initForward()
->setControllerName('controllername')
->setModuleName('modulename')
->setActionName('actionname')
->setDispatched(false);
@wsagen
wsagen / Magento Log stack trace
Created October 31, 2014 05:26
Magento log stack trace
private function get_callstack() {
$dt = debug_backtrace();
$cs = array();
foreach ($dt as $t) {
$cs[] = $t['file'] . ' line ' . $t['line'] . ' calls ' . $t['function'] . "()" ;
}
return $cs;
}
@wsagen
wsagen / gist:0b94949edcd719e43428
Created December 11, 2014 12:56
Magento PHP to Reload ACL so users don't have to logout and back in again after installing the extension.
https://github.com/schmengler/AclReload/blob/master/src/app/code/community/SSE/AclReload/controllers/Adminhtml/Permissions/AclReloadController.php
$session = Mage::getSingleton('admin/session');
$session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
@wsagen
wsagen / gist:a925678cc6e2db57c8d9
Created November 26, 2015 13:25
Install and enable module in Magento 2
php -f bin/magento module:enable --clear-static-content Module_Name
php -f bin/magento setup:upgrade
@wsagen
wsagen / gist:bb4967aff9125832ea6b
Created December 1, 2015 05:56
Change admin URL in magento2
To change the url open the file env.php in the path app/etc
array (
'frontName' => 'admin', // Default name which we was given at the time of installation.
),
@wsagen
wsagen / gist:678250ab08d34a1a9310
Created December 3, 2015 13:24
Update to controller not working in M2 ?
Delete contents of var/generation and refresh
@wsagen
wsagen / gist:c4858114e9a094e4b04e
Created March 1, 2016 03:17
Authentication for M2 installation via composer
Follow instructions here to generate keys
http://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html
When using composer install command, enter public key and private key as username and password, if prompted
If not prompted and get authentication error
Add public and private key as username and password in your auth.json file found in a hidden .composer folder in the ~/User/{Home Directory}/ directory.