Magento observer not being triggered by event - magento

I'm trying to add a module to Magento, which attaches an observer to the sales_order_invoice_register event, but having trouble getting it to work.
I have a small script that just does the following:
require_once('app/Mage.php');
Mage::app();
Mage::dispatchEvent('sales_order_invoice_register');
When I execute that script from the command line in the root of the Magento installation, the observers method is triggered as expected, so I think everything is correctly configured with the module (within the global section of my modules config.xml).
However, when I create an order and then ship and invoice it from the admin pages, I can see the event gets dispatched but the observer does not get triggered. This seems to be because the getEventConfig() method of Config.php when it looks up $_eventAreas['global'] does not contain the entry I added in my own config.xml (nor any other entry for the sales_order_invoice_register event). Does anyone have any ideas how this could occur, and what to do to fix it ?

Sorry, am going to answer my own question.
Had been looking at it for a couple of hours, just writing it out above made me notice something more emphatically. How could it work when running from the command line and not through apache ? Configuration had to be fine, unfortunately file ownership was not. I was running from the command line with my own user, not the web service user. I had created the module config files with my own user rather than with the web service user. Therefore for the web service process when scanning the module directories, my new module config would have been invisible causing it not to be loaded. I just chowned the files to the web service user and it worked immediately.

Related

Magento 1.4.1.1 can't log into the admin area after installing module

I installed a new module and now I get this error and can't log into the admin area of Magento:
Warning: include(Mage/Awautorelated/Helper/Data.php): failed to open stream: No such file or directory in /var/www/spasandstuff.com/lib/Varien/Autoload.php on line 93
I have removed the module, cleared the cache and session folders and it still gives me that error.
I ran grep -r "Awautorelated" * and found nothing on the server. I restarted Apache to clear APC cache. Magento uses Lightspeed but I believe that just uses the Magento cache directory which I cleared. So I am at a loss as to how to fix this issue. Is there a database table that caches module info?
Any help will be greatly appreciated.
Somewhere, a piece of Magento code is attempting to instantiate a helper class with code that looks something like
Mage::helper('awautorelated');
Mage::helper('awautorelated/data');
Since you've removed the module from the server and cleared your cache, there's no <model> node for the <awautorelated> group. That's why Magento is looking for this class in Mage/Awautorelated instead of AW/Awautorelated.
Based on everything you've said, my guess is you have an XML file somewhere, likely in the layout, that still contains an attribute something like this
<sometag ... module="awautorelated" ...>
These module attributes are used to specify a translation helper for "inner nodes". Your Magento system loads the XML file, parses it, sees the module="awautorelated", and then attempts to instantiate a awautorelated helper to translate the nodes. Since you've remove that module files, it can't instantiate the helper and yells at you. Try a case insensitive grep (or ack)
grep -i -r 'awautorelated'
and make sure you search the entire Magento source tree. Not just app/code, but app/design as well.
Did you remove
AW_All.xml
AW_Productrelater.xml
from /app/etc directory
Yes, there is the table core_config_data, but I don't expect removing the module entry from their will be realted to this problem, but you can certainly remove the entry now the module has been removed.
Are you using memcached for caching? you could remove that. I'm not 100% sure restarting apache clears the APC cache either ...

file/page not found when uploaded online

I am working on a new module of existing live project. It is a website developed in PHP Zend Framework. New module is on admin side. It runs properly on my localhost/virtualhost.
When I uploaded it online with correct directory path it is found that one file is not found.
It is called like
www.example.com/admin/controllerName/actionName
All the actions works except one action that doesn't display anything and returns exception error mentioning that page or file not found.
What could be the issue? I have checked folders. If one action for the same controller works than why doesn't other. Both have their .phtml files in View section.
Help would be appreciated.
Would I be right if I guessed your local development environment was Windows?
It's probably a filename case sensitivity issue.
Assuming your request looks like
www.example.com/admin/fusionmaps/newpage
I'm not sure how you've setup your modules but if it's reasonably standard, you should have something like this (note the upper and lowercase characters)
application/modules/admin/controllers/FusionmapsController.php
The controller classname should be Admin_FusionmapsController with action public function newpageAction()
The view script should be at
application/modules/admin/views/scripts/fusionmaps/newpage.phtml

Save file in magento after checkout completation

I need to save a file after a succesfully checkout. So I'm using the checkout_type_onepage_save_order_after event. When checking out, it stucks if I have some shitty code in there but it goes nicely if I have valid code in the observer. So it gets called, at least I think it does. Can't test it since it doesn't write my file, doesnt write anything in the log etc. So, what could be wrong? Why doesn't it write some stuff into the log? As I said, with other events it works perfectly. It's a new magento installation.
http://pastebin.com/TWyj6CYt cache is disabled. I'm using 1.5
I suggest you use the following event : sales_model_service_quote_submit_after
This event triggers right after the successful creation of an order.
You can also use Mage::log("Observer called"); just to check if your event observer is being invoked.
I hope this helps you :)
You have a class name Xxx_saveCheckout_Model_Observer. Class name parts usually all have uppercase initial letters, the autoloader expects that. Try changing it to Xxx_SaveCheckout_Model_Observer (with a capital 'S').
Also make sure the config file has a /config/global/models section, although it might be missing from your pastebin on purpose.

Codeigniter App on EC2 - Helpers not loading

I recently just started to migrate over a CI application to Amazon's EC2 service. To test I set up a micro instance of ubuntu and a LAMP stack. PHP, MySQL, HTTPD are all working beautifully. The one issue i'm having now is that when I run my application I receive an error saying that my helpers won't load. The helpers in particular that aren't loading are the ones in subdirectories in the helpers directory ie: /var/www/system/application/helpers/subdirectory/foo_helper.php
The helpers are being autoloaded and in my autoload.php config file they are written like:
$autoload['helper'] = array('subdirectory/foo', 'foo2',...);
Has anyone run into this issue, or have any pointers on where I could go look in my configuration to resolve this?
Thanks for the help!
I'd try debugging the helper function of the Loader class, in particular these lines :
system/libraries/Loader.php
elseif (file_exists(APPPATH.'helpers/'.$helper.EXT))
{
include_once(APPPATH.'helpers/'.$helper.EXT);
}
This is the code that will be hit when including application helpers. Check what path CodeIgniter is trying to include. Double check that the path exists - everyone makes typos now and again ;-)
I think the issue is that when I moved from Windows to Linux I forgot to take into account that linux is case-sensitive. So now I need to go through and rename my files and folders.
But this still doesn't solve the issue where it seems like the page is being cached and I'm not able to refresh and see my changes. Is there any way to force the page to grab a fresh copy from the server on every refresh?

db:migrate order in Spree

I'm using spree and created a new payment gateway extension. The problem is, my newly created payment gateway gets created first before the core payment gateway of spree. Here's the error message.
doesn't exist: SHOW FIELDS FROM gateway_options
I've had the same problem. Basically, there's a way to define the order in which extensions are loaded but not when their migrations are ran.
config.extensions = [:all, :site]
More info here.
The way I do it, is simply by renaming the "db" folder of the extensions' migrations needing to be ran later. When the others have ran, I rename it back to its original name and run the migrations again. Dirty, but it works.
There could probably be a way to make a rake task and automate this.

Resources