Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Event dispatch requests
 
wolvax
Jr. Member
 
Total Posts:  9
Joined:  2011-01-13
 

I need an event every time a “transactional email” is sent.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kamaljoshi
Member
 
Avatar
Total Posts:  46
Joined:  2011-01-11
Ahmedabad
 

Hey guys,

I am creating a custom payment module in which every consumer has its own account in which some amount is given to him , if consumer wish to pay by that account then amount will be deduct from that. Now i have created that payment module in which user can specify amount that what amount should be deduct from his account. In this module when user presses place order button at that time authorize method is called, if authorization is completed then quote is converted to payment but now i want to make changes to this, now the amount calculation should done after this. I dont know how to make this happen.

REGARDS,
KAMAL JOSHI

 
Magento Community Magento Community
Magento Community
Magento Community
 
kamaljoshi
Member
 
Avatar
Total Posts:  46
Joined:  2011-01-11
Ahmedabad
 

Sorry guys,

Its done. Actually i think that any event generated there, i have to change it but its done without overriding it. I am confused what instance i m getting there.

REGARDS,
KAMAL JOSHI

 
Magento Community Magento Community
Magento Community
Magento Community
 
danshields
Member
 
Total Posts:  32
Joined:  2009-03-11
 

I would like there to be an event dispatched after almost all prepareForm addFields so that we can addFields to forms through events rather then having to override them. Right now there are only like 6 of them for example “adminhtml_cms_page_edit_tab_main_prepare_form”. If there is another way to do this let me know, but I don’t see how to tie into them before the values are set.

 
Magento Community Magento Community
Magento Community
Magento Community
 
FishPig
Sr. Member
 
Avatar
Total Posts:  232
Joined:  2009-06-05
 

Would it be possible to add an event when the sitemap is created? This would allow certain modules to inject pages they create into the sitemap.

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 

Two questions (sorry if they have been asked before! I\’ve spent some Google time with no results)

How can I make a redirect to an admin controller work inside an Observer context?
I have tried passing both the Request object, the Response object, even the whole Controller object as data to the observer, and then doing something like…

...
->
getResponse()->setRedirect(Mage::getUrl(\"admin/promo_quote\"));
...

But it redirects just ignoring the \’admin\’ part
I\’ve tried with Mage::helper(\’adminhtml\’)->getUrl() function, but result is the same…

And the second question is…
Are there some default events for the admin controllers, as the Model default events?
I\’ve found the adminhtml_controller_action_predispatch_start event, but I am afraid it doesn\’t work for my purposes after some tests

Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 
raulsanchez - 12 September 2011 06:06 AM

And the second question is…
Are there some default events for the admin controllers, as the Model default events?
I\’ve found the adminhtml_controller_action_predispatch_start event, but I am afraid it doesn\’t work for my purposes after some tests

Thanks!

Around this…
I’ve found, as Mage_Adminhtml_Controller_Action class extends Mage_Core_Controller_Varien_Action, we can use controller_action_predispatch event in admin environment

 
Magento Community Magento Community
Magento Community
Magento Community
 
jschmahl
Jr. Member
 
Total Posts:  17
Joined:  2010-09-24
 

Hi Magento Community,
I’m searching to an event which is placed before “checkout_submit_all_after” and if I place an error to the “Mage::getSingleton(’checkout/session’)->addError("errortext");" the saving process is aborted and the user is redirected to the cart.

Thank you for your help.

Greetings jschmahl

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 
raulsanchez - 12 September 2011 06:06 AM

Two questions (sorry if they have been asked before! I\’ve spent some Google time with no results)

How can I make a redirect to an admin controller work inside an Observer context?
I have tried passing both the Request object, the Response object, even the whole Controller object as data to the observer, and then doing something like…

...
->
getResponse()->setRedirect(Mage::getUrl(\"admin/promo_quote\"));
...

But it redirects just ignoring the \’admin\’ part
I\’ve tried with Mage::helper(\’adminhtml\’)->getUrl() function, but result is the same…

http://www.magentocommerce.com/boards/viewthread/261242/

??

 
Magento Community Magento Community
Magento Community
Magento Community
 
manish_iitg
Sr. Member
 
Total Posts:  260
Joined:  2009-05-02
 

I have written a blog post on events for people want to learn on how to use events.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CasadVance
Jr. Member
 
Total Posts:  1
Joined:  2011-10-06
 

I am having a similar problem to raulsanchez.

How can I make a redirect to an admin controller work inside an Observer context?

Does anyone have an answer to this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
raulsanchez
Sr. Member
 
Avatar
Total Posts:  83
Joined:  2011-02-22
 
CasadVance - 06 October 2011 02:33 PM

I am having a similar problem to raulsanchez.

How can I make a redirect to an admin controller work inside an Observer context?

Does anyone have an answer to this?

http://www.magentocommerce.com/boards/viewthread/261242/
It would be nice someone give some technical review there

 
Magento Community Magento Community
Magento Community
Magento Community
 
ryanstreet
Jr. Member
 
Avatar
Total Posts:  28
Joined:  2011-07-13
Dayton, OH
 

I would like an event added to Import/Export just after your file is uploaded, and before it is processed.  This way you can manipulate, sanitize, or check the data against your own custom modules.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tuongaz1
Jr. Member
 
Total Posts:  1
Joined:  2011-03-04
 

I would like to have an event when the a revision is published in CMS (Enterprise version).

 
Magento Community Magento Community
Magento Community
Magento Community
 
thylaksoft
Sr. Member
 
Avatar
Total Posts:  78
Joined:  2009-12-10
New Castle, DE
 

Step 1

Create a new attribute ‘percent_discount‘.

Attrib Identifier –percent_discount , Scope – Store View , Catalog I/p – Text , Unique Value – No , Values Required – NoInput , Validation –Decimal , Apply to Configurable/All Product Types - Yes

Use in quick search – No , Advanced Search – No , Comparable – No , Visibile on Frontend – Yes , Attribute Label – % Discount
Step 2

Add this new attribute to your attributeset. If your product’s attributeset is ‘default‘, add the new ‘percent_discount’ attribute to this attributeset under “prices” attribute group.
Step 3

Register a new custom local module under name ‘Xyz’. For this create file ‘Xyz.xml’ under directory ‘app/etc/modules/’. File contents are -

<?xml version="1.0"?>
<config>
<modules>
<Xyz_Catalog>
<codePool>local</codePool>
<active>true</active>
</Xyz_Catalog>
</modules>
</config>

Step 4

Register the event with its Observer. Create file ‘config.xml’ under directory ‘app/code/local/Xyz/Catalog/etc/’ with contents as -

<?xml version="1.0"?>
<config>
<global>
<models>
<xyzcatalog>
<class>Xyz_Catalog_Model</class>
</xyzcatalog>
</models>
<events>
<catalog_product_get_final_price>
<observers>
<xyz_catalog_price_observer>
<type>singleton</type>
<class>Xyz_Catalog_Model_Price_Observer</class>
<method>apply_discount_percent</method>
</xyz_catalog_price_observer>
</observers>
</catalog_product_get_final_price>
</events>
</global>
</config>

Step 5

Creating the Observer. Create the directory structure - app/code/local/Xyz/Catalog/Model/Price/. Place the php code below in a file by name ‘Observer.php’ in the directory just created.

<?php
class Xyz_Catalog_Model_Price_Observer
{
public function __construct()
{
}
/**
* Applies the special price percentage discount
* @param Varien_Event_Observer $observer
* @return Xyz_Catalog_Model_Price_Observer
*/
public function apply_discount_percent($observer)
{
$event = $observer->getEvent();
$product = $event->getProduct();
// process percentage discounts only for simple products
if ($product->getSuperProduct() && $product->getSuperProduct()->isConfigurable()) {
} else {
$percentDiscount = $product->getPercentDiscount();

if (is_numeric($percentDiscount)) {
$today = floor(time()/86400)*86400;
$from = floor(strtotime($product->getSpecialFromDate())/86400)*86400;
$to = floor(strtotime($product->getSpecialToDate())/86400)*86400;

if ($product->getSpecialFromDate() && $today < $from) {
} elseif ($product->getSpecialToDate() && $today > $to) {
} else {
$price = $product->getPrice();
$finalPriceNow = $product->getData(’final_price’);

$specialPrice = $price - $price * $percentDiscount / 100;

// if special price is negative - negate the discount - this may be a mistake in data
if ($specialPrice < 0)
$specialPrice = $finalPriceNow;

if ($specialPrice < $finalPriceNow)
$product->setFinalPrice($specialPrice); // set the product final price
}
}
}
return $this;
}
}

Step 6

NOTE: To get Magento to load the changed local code configuration, one needs to (temporary) disable caching of code configuration. In admin panel, go to System > Cache management and uncheck the Configuration option.

Set the discount on the product. Navigate to the catalog product on the admin login and edit a product. Set the percentage discount for this product (under prices subtab).
Step 7

Navigate to the product details page on the front end and observe that the new discount has taken effect. To be noted here is that, on all other screens where discounted price is required. An example here is the search results screen, where you would need to add this new attribute to the select query search attributes in method Mage_CatalogSearch_Block_Result→_getProductCollection()

$_productCollection= $_productCollection->addAttributeToSelect(’percent_discount’);

Thanks,
Thylaksoft LLC

If you need more details Please contact us :

302-355-0449

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top