How to User sales_order_place_after for Recurring Profile - magento

I am using sales_order_place_after event in observer event
<sales_order_place_after>
<observers>
<Test_Check_Model_Observer>
<type>singleton</type>
<class>Test_Check_Model_Observer</class>
<method>SubscribePlan</method>
</Test_Check_Model_Observer>
</observers>
</sales_order_place_after>
Then My Observer.php's Method SubscribePlan Contains
public function SubscribePlan($observer) {
die('getting called');
}
This event is Working but when i Place Order for Recurring Profile this event doesn't work, Can some one please Tell me any alternate event which also works for recurring profile after placing order

Here the code
<global>
<models>
<test>
<class>Test_Check_Model</class>
</test>
</models>
<events>
<events>
<sales_order_place_after>
<observers>
<mysales_order_observer>
<type>singleton</type>
<class>test/observer</class>
<method>SubscribePlan</method>
</mysales_order_observer>
</observers>
</sales_order_place_after>
</events>
</global>

I'm looking for something similar recently and my solution is
override model Mage_Sales_Model_Recurring_Profile with your own model
Inside your own model, set property $_eventPrefix to for example "recurring_profile"
create observer for event recurring_profile_save_commit_after.
If you need exactly the event when profile is created, you may need to override submit method and either dispatch a customized event or just put all code there without using event/observer at all.
P.S. I used Magento 1.9.3.2

Related

What is the event that will fire after assigning customer to group in Magento?

I have to fire an observer method when the admin assign customer(s) to group on adminhtml. Can you help me which event is it?
I tried adminhtml_customer_save_after but it didn't worked.
You can use any one event below
customer_save_before,
customer_save_after
<global>
<events>
<customer_save_after>
<observers>
<change_customer_group>
<type>singleton</type>
<class>modulename/observer</class>
<method>ChangeCustomerGroup</method>
</change_customer_group>
</observers>
</customer_save_after>
</events>
</global>

Magento - How can i run function when the checkout page is opened?

I am using Magento 1.9.2 and i am working on a custom extension.
My question is:
How can i run custom php function when the checkout page is opened?
I know i have to mess around with the events of the extension config file but i am not exactly sure how i can point the function in the observer which i want to run when the checkout page is opened.
Here is events part of my config:
<events>
<controller_action_postdispatch_opc_json_saveOrder>
<observers>
<hss_save_order_onepage>
<class>paypal/observer</class>
<method>setResponseAfterSaveOrder</method>
</hss_save_order_onepage>
</observers>
</controller_action_postdispatch_opc_json_saveOrder>
<sales_order_place_before>
<observers>
<custom_ads>
<class>opc/observer</class>
<method>checkitemsincartv</method>
</custom_ads>
</observers>
</sales_order_place_before>
<sales_order_place_after>
<observers>
<newsletter_order_place_after>
<class>opc/observer</class>
<method>newsletter</method>
</newsletter_order_place_after>
</observers>
</sales_order_place_after>
<checkout_submit_all_after>
<observers>
<opc_checkout_submit_all_after>
<class>opc/observer</class>
<method>applyComment</method>
</opc_checkout_submit_all_after>
</observers>
</checkout_submit_all_after>
</events>
Here is the function that i want to run:
public function checkitemsincartv($observer)
{
Mage::getSingleton('core/session')->setItemsInCart("Works");
$data = $observer->getEvent()->getOrder();
Mage::log($data->debug(), null, "order.log", true);
}
How can i achieve that?
Thanks in advance!
You need to use the event - controller_action_predispatch_checkout_onepage_index or controller_action_postdispatch_checkout_onepage_index All controllers inherit the preDispatch or postDispatch method which fires a generic event for predispatch/postdispatch, and a specific event based on the requested action path.
The controller you need is in the checkout module and is called onepage with a default action of index.
Checkout Mage_Core_Controller_Varien_Action::preDispatch() or Mage_Core_Controller_Varien_Action::postDispatch() to see the relevant code

Magento Lost Style after checkout_onepage_controller_success_action

<events>
<checkout_onepage_controller_success_action>
<observers>
<sendmail>
<type>singleton</type>
<class>Xkey_Redegrupo_Model_Observer</class>
<method>sendMailRGroup</method>
</sendmail>
</observers>
</checkout_onepage_controller_success_action>
</events>
If I change the checkout_onepage_controller_success_action to sales_order_after_save, work but send 2 times the e-mail, when I use this, the e-mail sends succefull but the layout of /onepage/checkout/success/ lost style ? Why? ! help me Ç.Ç
Kin checkout_onepage_controller_success_action is an event is occur after order has successfully place and redirected to checkout/onepage/success pages.it an fronted event.sales_order_after_save is global event and it is run when you save order. several time are occurs during order procedure....
Exmple of event
<checkout_onepage_controller_success_action>
<observers>
<create_invoice_for_zero_payment>
<class>zerosubtotalpaymentmethod/createinvoice</class>
<method>automaticinovoice</method>
</create_invoice_for_zero_payment>
</observers>
</checkout_onepage_controller_success_action>

Custom "Catalog Input Type for Store Owner" for magento product attributes

In magento you can create new attributes (which are then added to attribute sets which products inherit) with certain types.
The default options (textfield/area, data, boolean) are fairly limited and I would like to add my own, complete with backend field renderer and its own validation. This to create a youtube field which accepts a range of urls which are transformed into only the youtube id.
But I'd really like a good explanation on how to add your own "Catalog Input Type for Store Owner". I've seen other plugins do it, but digging through code is tedious and this is definitely something which interests other people as well (question gets asked a lot over the web).
I have been searching for a while, but to no avail, I will continue to hunt down the answer until I find it however.
tl;dr
So my question is: How to add a "Catalog Input Type for Store Owner", maybe with a reference how to add a custom validation to this field type. This in the proper MVC style, so no editing of core files if possible.
Bonus points for being elaborate, generic explanations & code examples, I will award a bounty based on the quality of answer, if it is worth it (since this will be applicable to a larger audience).
Sorry, I don't have time for writing long answer. Next 4 observers from Wee module will give you needed directions:
<config>
<global>
<events>
<catalog_entity_attribute_save_before>
<observers>
<weee>
<type>model</type>
<class>weee/observer</class>
<method>assignBackendModelToAttribute</method>
</weee>
</observers>
</catalog_entity_attribute_save_before>
</events>
</global>
...
<adminhtml>
<events>
<adminhtml_catalog_product_edit_prepare_form>
<observers>
<weee>
<class>weee/observer</class>
<method>setWeeeRendererInForm</method>
</weee>
</observers>
</adminhtml_catalog_product_edit_prepare_form>
<adminhtml_product_attribute_types>
<observers>
<weee>
<type>model</type>
<class>weee/observer</class>
<method>addWeeeTaxAttributeType</method>
</weee>
</observers>
</adminhtml_product_attribute_types>
<adminhtml_catalog_product_edit_element_types>
<observers>
<weee>
<class>weee/observer</class>
<method>updateElementTypes</method>
</weee>
</observers>
</adminhtml_catalog_product_edit_element_types>
</events>
</adminhtml>
</config>

Make a custom observer fire before an existing Magento observer

Is there a way to make an observer that you have custom made have higher priority than the Magento one that fires on the same event. My problem is I am modifying the output of the Welcome block but the PageCache for enterprise fires on the same corecore_block_abstract_to_html_after event.
I tried putting this in my config but it didn't work like cron jobs do.
<core_block_abstract_to_html_after>
<observers>
<modify_welcome>
<type>singleton</type>
<class>groupname_page/observer</class>
<method>changeWelcomeText</method>
</modify_welcome>
<enterprise_pagecache>
<class>enterprise_pagecache/observer</class>
<method>renderBlockPlaceholder</method>
</enterprise_pagecache>
</observers>
</core_block_abstract_to_html_after>
/app/etc/modules/Groupname_Page.xml
<config>
<modules>
<Groupname_Page>
<active>true</active>
<codePool>local</codePool>
<depends>
<!-- Your dependencies go here -->
</depends>
</Groupname_Page>
<Enterprise_PageCache>
<depends>
<Groupname_Page />
</depends>
</Enterprise_PageCache>
</modules>
</config>
There is no way to control order of observers.
If you take a look on the Mage_Core_Model_App::dispatchEvent() method, you'll see how Magento get all observers for a given event from config.xml files and fires them one by one.
Rewriting the Welcome block will help you.
another option is to disable the enterprise cache observer and in your own observer run the method that would have been executed by the disabled observer
In your module's config.xml:
<core_block_abstract_to_html_after>
<observers>
<modify_welcome>
<type>singleton</type>
<class>groupname_page/observer</class>
<method>changeWelcomeText</method>
</modify_welcome>
<enterprise_pagecache>
<type>disabled</type>
</enterprise_pagecache>
</observers>
</core_block_abstract_to_html_after>
And in your Observer.php:
public function changeWelcomeText(Varien_Event_Observer $observer)
{
//do the stuff you want your observer to do first
//and after it's done, call the Enterprise observer's method
Mage::getSingleton('enterprise_pagecache/observer')->renderBlockPlaceholder($observer);
}
HTH

Resources