Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:30:09+00:00 2026-06-14T11:30:09+00:00

Following this post I’ve finally managed to capture an event by extending the Magento_Adminhtml_Controller_Action

  • 0

Following this post I’ve finally managed to capture an event by extending the Magento_Adminhtml_Controller_Action and carry out some actions before it. But now I’m trying to improve it so I can capture another event triggered on the admin panel and from there pass an array through the request variable to another event on the frontend. I’ve these SO questions/answers, here and here but no way I can achieve what I need. I’ve tested the observer code using die() to be sure that the execution thread goes into the correct call and it is ok. I’m using the CommerceBug from AlanStorm, in case it can be used to get some light on this issue.

This is my Observer.php code.

<?php
class Dts_Videotestimonials_Model_Observer {

    public function hookToAdminhtmlControllerActionPreDispatch($observer)
    {
        if($observer->getEvent()->getControllerAction()->getFullActionName() == 'videotestimonials_adminhtml_videotestimonialsbackend_post')
        {
            // dispatching our own event before action upload video is run and sending parameters we need
            Mage::dispatchEvent("upload_video_before", array('request' => $observer->getControllerAction()->getRequest()));
        }
    }

    public function hookToUploadVideoBefore($observer)
    {
        //Hooking to our own event
        $request = $observer->getEvent()->getRequest()->getParams();
        // do something with product

        $user = Mage::getSingleton('admin/session');
        $userName = $user->getUser()->getFirstname();
        $userEmail = $user->getUser()->getEmail();

        $request['product_id'] = "16"; #$_product->getId(),
        $request['author_email'] = $userEmail;
        $request['author_name'] = $userName;
        $request['video_link'] = "http://www.youtube.com/watch?v=y435u6kfExA&feature=youtube_gdata_player";
        $request['video_type']  = "link";
        $request['title'] = "AT&T Phone Nokia 2610";
        $request['comment'] = "this is a comment";
        Mage::dispatchEvent("vidtest_youtube_post", $request);
    }
}

EDITED:

Here is the full config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Dts_Videotestimonials>
            <version>0.1.0</version>
        </Dts_Videotestimonials>
    </modules>
    <global>
        <models>
          <videotestimonials>
            <class>Dts_Videotestimonials_Model</class>
            <resourceModel>videotestimonials_mysql4</resourceModel>
          </videotestimonials>
        </models>
        <events>
            <controller_action_predispatch>
                <observers>
                    <controller_action_before>
                        <type>singleton</type>
                        <class>videotestimonials/observer</class>
                        <method>hookToAdminhtmlControllerActionPreDispatch</method>
                    </controller_action_before>
                </observers>
            </controller_action_predispatch>
            <upload_video_before>
                <observers>
                    <upload_video_before>
                        <type>singleton</type>
                        <class>videotestimonials/observer</class>
                        <method>hookToUploadVideoBefore</method>
                    </upload_video_before>
                </observers>
            </upload_video_before>
        </events>
        <helpers>
            <videotestimonials>
                <class>Dts_Videotestimonials_Helper</class>
            </videotestimonials>
        </helpers>
        <blocks>
          <videotestimonials>
            <class>Dts_Videotestimonials_Block</class>
          </videotestimonials>
        </blocks>
    </global>
    <admin>
        <routers>
          <videotestimonials>
            <use>admin</use>
            <args>
              <module>Dts_Videotestimonials</module>
              <frontName>videotestimonials</frontName>
            </args>
          </videotestimonials>
        </routers>
    </admin>
    <adminhtml>
        <menu>
          <videotestimonials module="videotestimonials">
            <title>Videotestimonials</title>
            <sort_order>100</sort_order>
            <children>
              <videotestimonialsbackend module="videotestimonials">
                <title>VideoTestimonials_Admin</title>
                <sort_order>0</sort_order>
                <action>videotestimonials/adminhtml_videotestimonialsbackend</action>
              </videotestimonialsbackend>
              <pending_video translate="title">
                  <title>Videos pendientes</title>
                  <sort_order>20</sort_order>
                  <action>videotestimonials/adminhtml_pendingvideos/pending</action>
              </pending_video>          
            </children>
          </videotestimonials>
        </menu>
        <acl>
          <resources>
            <all>
              <title>Allow Everything</title>
            </all>
            <admin>
              <children>
                <videotestimonials translate="title" module="videotestimonials">
                  <title>Videotestimonials</title>
                  <sort_order>1000</sort_order>
                  <children>
                    <videotestimonialsbackend translate="title">
                        <title>VideoTestimonials_Admin</title>
                    </videotestimonialsbackend>
                    <pending_video translate="title">
                      <title>Videos pendientes</title>
                      <sort_order>20</sort_order>
                    </pending_video>
                  </children>
                </videotestimonials>
              </children>
            </admin>
          </resources>
        </acl>
        <layout>
          <updates>
            <videotestimonials>
              <file>videotestimonials.xml</file>
            </videotestimonials>
          </updates>
        </layout>
    </adminhtml>
    <crontab>
        <jobs>            
            <videotestimonials_videotestimonialscron>
                <schedule><cron_expr>59 0 * */1 0</cron_expr></schedule>
                <run><model>videotestimonials/cron::VideoTestimonialscron</model></run>
            </videotestimonials_videotestimonialscron>
        </jobs>
    </crontab>
</config> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:30:11+00:00Added an answer on June 14, 2026 at 11:30 am

    Here is what is happening. Your configuration of the admin controller is wrong. The proper way to include your controller in the admin section is this (you’ll need to change out the module name, to match yours):

    <?xml version="1.0" ?>
    
    <config>
        <modules>
            <Video_Awesome>
                <version>0.0.1</version>
            </Video_Awesome>
        </modules>
        <global>
            <models>
                <Video_Awesome>
                    <class>Video_Awesome_Model</class>
                    <!-- No resource model used currently -->
                </Video_Awesome>
            </models>
            <events>
                <controller_action_predispatch>
                    <observers>
                        <controller_action_before>
                            <type>singleton</type>
                            <class>Video_Awesome/Observer</class>
                            <method>controllerActionPredispatch</method>
                        </controller_action_before>
                    </observers>
                </controller_action_predispatch>
                <upload_video_before>
                    <observers>
                        <Video_Awesome>
                            <type>singleton</type>
                            <class>Video_Awesome/Observer</class>
                            <method>uploadVideoBefore</method>
                        </Video_Awesome>
                    </observers>
                </upload_video_before>
            </events>
        </global>
    
        <admin>
            <routers>
                <adminhtml>
                <!-- we are not creating our own router, but tapping into the adminhtml router -->
                    <args>
                        <modules>
                            <!-- Your module name, and then
                            the path to the controller (minus
                            the controllers folder name). So,
                            in this instance, I put the router
                            in a "Adminhtml" folder inside of
                            the controllers folder, like thus:
            Video/Awesome/controllers/Adminhtml/videotestimonialsController.php -->
                            <Video_Awesome before="Mage_Adminhtml">Video_Awesome_Adminhtml</Video_Awesome>
                        </modules>
                    </args>
                </adminhtml>
            </routers>
        </admin>
    </config>
    

    And, then, in your router (you don’t need to call getEvent before getting the controller action):

    public function controllerActionPredispatch ($observer)
    {
        if($observer->getControllerAction()->getFullActionName() == 'adminhtml_videotestimonials_post') {
            // dispatching our own event before action upload video is run and sending parameters we need
        Mage::dispatchEvent("upload_video_before", array('request' => $observer->getControllerAction()->getRequest()));
        }
    }
    

    And finally, it doesn’t sound as if you have a debugging setup for your Magento development. I would highly recommend one. I use PHPStorm (I don’t have any stake in the company – this is not an advertisement :), and it works awesome. Set a breakpoint there to see if what the variables are.

    I would also recommend using adminhtml_controller_action_predispatch_start, instead of the global controller_action_predispatch, as it will only trigger in the backend (a very, very small performance difference).

    Also, as a small sidenote, I saw in your config.xml, that you were specifying menu items/acl there. You probably didn’t know, but that is deprecated functionality, and those items should be put it adminhtml.xml.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following this post which I posted some time ago, I now get the same
The following is some background info on this post. You can just skip to
In this post Jon Skeet pointed out that the following code should be changed
Following this SO post I was able to take screenshots but they turned out
I've been following this post http://martinciu.com/2011/01/mounting-grape-api-inside-rails-application.html I put the module into the lib directory
What could be the understanding of the following? I have gone through this post
I'm following the instructions on using xsi:type from this oft-cited blog post: http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-xsitype.html Basically
Following this post (I was looking for a library allowing me to declare Django
Following this post I have created a WCF client which: Uses ADFS to authenticate
My question is similar to this following post Render a view of another controller

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.