/** * Override? * * @param unknown_type $observer */ public function initControllerRouters($observer) { $front = $observer->getEvent()->getFront(); /** @var Mage_Core_Controller_Varien_Front $front * */ $rewards = new TBT_Rewards_Controller_Router(); //$front->addRouter('rewards', $rewards); }
/** * This observes the event of a customer liking something * on facebook. Whenever the like button is pressed on any * page, the details of that action are passed through this * observer to record and create transfers from. * * The event should contain the following details: * * facebook_account_id - identifies which facebook account liked the url * liked_url - identifies which url (product, category, page, etc) was liked * * @param unknown_type $o */ public function facebookLikeAction($o) { $event = $o->getEvent(); $facebook_account_id = $event->getFacebookAccountId(); $liked_url = $event->getLikedUrl(); $customer = $this->getCurrentlyLoggedInCustomer(); if (!$customer) { return $this; } $this->initReward($facebook_account_id, $liked_url, $customer); return $this; }
/** * Enter description here ... * @param unknown_type $observer * @return EmjaInteractive_PurchaseorderManagement_Model_Adminhtml_Sales_Order_View_Observer */ public function prepareButtons($observer) { $block = $observer->getEvent()->getBlock(); if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) { $order = $block->getOrder(); $payment = $order->getPayment(); if ($payment && $payment->getMethod() == 'purchaseorder' && $order->canShip()) { $block->removeButton('order_invoice'); } $block->addButton('print', array('label' => Mage::helper('sales')->__('Print'), 'class' => 'save', 'onclick' => 'setLocation(\'' . Mage::getModel('adminhtml/url')->getUrl('adminhtml/po_sales_order/print', array('order_id' => $order->getId())) . '\')')); } return $this; }
/** * Attempts to retreive a product ID from the observer or the previously dispatch observer. * @param unknown_type $observer */ protected function _locatedProductId($observer) { $target_product_id = null; $event = $observer->getEvent(); $action = $observer->getControllerAction(); if ($action) { $request = $action->getRequest(); $target_product_id = $request->getParam("id"); if (!$target_product_id) { $target_product_id = null; } //if no product id available, reset our assumption because this must be some other unrecognized request. } $product = $observer->getProduct(); if (empty($product) && $event instanceof Varien_Event) { $product = $event->getProduct(); } if ($product) { $target_product_id = $product->getEntityId(); if (!$target_product_id) { $target_product_id = null; } } if ($target_product_id) { // IF a product ID was fetched, set it into the registry if (Mage::registry('rewards_catalogrule_apply_product_id_memory')) { Mage::unregister('rewards_catalogrule_apply_product_id_memory'); } Mage::register('rewards_catalogrule_apply_product_id_memory', $target_product_id); } else { // IF a product ID was NOT fetched, attempt to get it from the registry if (Mage::registry('rewards_catalogrule_apply_product_id_memory')) { $target_product_id = Mage::registry('rewards_catalogrule_apply_product_id_memory'); // After pulling it from the registry, remove it from the registry so the next immediate action does not recall this. Mage::unregister('rewards_catalogrule_apply_product_id_memory'); } } return $target_product_id; }
/** * Gets triggered on the checkout_cart_add_product_complete event to append points information * @see Mage::dispatchEvent('checkout_cart_add_product_complete', array('product'=>$product, 'request'=>$this->getRequest())); * @param unknown_type $o */ public function updateOnProductAddComplete($o) { $product = $o->getEvent()->getProduct(); $request = $o->getEvent()->getRequest(); $this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals(); return $this; }
/** * Validate / update a model before saving it * * @param unknown_type $observer */ public function validateModelSaveBefore($observer) { if ($this->_role->getIsAll()) { return; } $model = $observer->getEvent()->getObject(); if (!($callback = $this->_pickCallback('model_save_before', $model))) { return; } $this->_invokeCallback($callback, 'enterprise_admingws/models', $model); }