Skip to content

Instantly share code, notes, and snippets.

View wsagen's full-sized avatar

Genevieve Eddison wsagen

View GitHub Profile
@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 / 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 / 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 / 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 / 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>