observers

Observer for Checkout Start

こ雲淡風輕ζ 提交于 2019-12-21 05:40:36
问题 Is there an observer in Magento to detect the start of the checkout process? This would include hitting the page checkout/onepage/ or checkout/onestepcheckout/ . I would like to avoid overriding controllers if possible. 回答1: Every controller action will result in multiple targeted events which are fired in Mage_Core_Controller_Varien_Action (link), the superclass for all action controllers. These events variously involve the "full action name," derived from module router configuration +

Is removing a NotificationCenter observer that was created with closure syntax by name adequate?

你离开我真会死。 提交于 2019-12-21 03:53:14
问题 I have a few notifications that were created using block / trailing closure syntax which look like this: NotificationCenter.default.addObserver(forName: .NSManagedObjectContextObjectsDidChange, object: moc, queue: nil) { note in // implementation } Which I was later removing by name, like this: NotificationCenter.default.removeObserver(self, name: NSNotification.Name.NSManagedObjectContextObjectsDidChange, object: moc) My Question Is this adequate? Or do I absolutely need to save the

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away on running cron job magento

核能气质少年 提交于 2019-12-20 18:42:32
问题 I am working on Magento site and I get this error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away on running cron job magento I only get this error sometimes. <?php class Namespace_Module_Model_Observer { public function importemails(Varien_Event_Observer $observer) { echo "Hi Dear";exit(); /* connect to gmail */ $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = 'myid@gmail.com'; $password = 'mypass'; /* try to connect */ $inbox = imap_open($hostname,$username,

SQLSTATE[HY000]: General error: 2006 MySQL server has gone away on running cron job magento

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 18:42:13
问题 I am working on Magento site and I get this error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away on running cron job magento I only get this error sometimes. <?php class Namespace_Module_Model_Observer { public function importemails(Varien_Event_Observer $observer) { echo "Hi Dear";exit(); /* connect to gmail */ $hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $username = 'myid@gmail.com'; $password = 'mypass'; /* try to connect */ $inbox = imap_open($hostname,$username,

Add custom calculation to cart total and grand total in magento

会有一股神秘感。 提交于 2019-12-19 10:47:30
问题 I am working on site where i want to add/subtract fee to cart total and grand total.I am firing this event to capture the cart details. sales_order_save_after . while in observer i got the price using this code public function modifyPrice(Varien_Event_Observer $obs) { $getotal = Mage::helper('checkout')->getQuote()->getGrandTotal(); $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); $subtotal = $totals["subtotal"]->getValue(); }. But i don't know how to add/subtract

Is there a way to get didSet to work when changing a property in a class?

故事扮演 提交于 2019-12-19 09:03:53
问题 I have a class as property with a property observer. If I change something in that class, is there a way to trigger didSet as shown in the example: class Foo { var items = [1,2,3,4,5] var number: Int = 0 { didSet { items += [number] } } } var test: Foo = Foo() { didSet { println("I want this to be printed after changing number in test") } } test.number = 1 // Nothing happens 回答1: Nothing happens because the observer is on test , which is a Foo instance. But you changed test.number , not test

Add 'addObserver' (NSNotificationCenter ) in a 1st view controller, handle in 2nd [duplicate]

女生的网名这么多〃 提交于 2019-12-19 06:19:14
问题 This question already has answers here : Send and receive messages through NSNotificationCenter in Objective-C? (6 answers) Closed 6 years ago . I saw a few examples about adding observer and handle in the same class, but what I want to know is if it's possible to add observer in first view controller and handle it in second view controller? I want constantly send distance from first view controller and handle it in the 2nd one. The 2nd view controller added as a sub view: addSubview ,

.childAdded observer doesn't get called If the function is not called explicitly. Swift 4

点点圈 提交于 2019-12-16 18:03:48
问题 I have a function that should listen to a Firebase node and get a snapshot of new posts when they get posted, but the function is not getting galled at all, as if the observer .observe(DataEventType.childAdded, with: { (snapshot) in didn't see new posts in the node. I checked and new posts are indeed registered in real time in Firebase. Should I call the function or is the observer that should do it? Heres the complete function: func getNewerAlerts(setCompletion: @escaping (Bool) -> ()) {

Check if a table's rows are being changed

时光毁灭记忆、已成空白 提交于 2019-12-13 02:37:45
问题 I would like to use a MutationObserver (or anything else at this point) to listen for changes in my table. My table -> tbody -> tr elements can be changed in various ways, such as: Filtering through search (which toggles an <tr> -element to show or hide) Filtering through checkboxes (again toggles them) Removes <tr> -elements By using a MutationObserver, I can go and check for changes in the table. It works when I remove an element (because the childList and subtree changes), but it does not

Callback before destroy and before associated records destroyed

房东的猫 提交于 2019-12-12 05:27:31
问题 I have the following model: class PhoneNumber < ActiveRecord::Base has_many :personal_phone_numbers, :dependent => :destroy has_many :people, :through => :personal_phone_numbers end I want to set up an observer to run an action in a delayed_job queue, which works for the most part, but with one exception. I want the before_destroy watcher to grab the people associated with the phone number, before it is destroyed, and it is on those people that the delayed job actually works. The problem is,