Save file in magento after checkout completation - magento

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.

Related

Phoenix error internationalization

I am translating my application through *.po-files, but the command
mix gettext.extract --merge
generates options only for hardcoded strings.
I have read in documentation that I can't edit *.po-files manually because they are overwritten every time.
How can I translate errors that come from changeset validations and so on?
dgettextfor errors is called in web/views/error_helpers.ex
I'm not sure if these get extracted and merged into errors.po, but that's where you'd likely put them manually if they do not.

Spree Commerce Shipping Calculators Not Found

I am trying to add a Shipping Method to my install (first time adding a shipping method). When I visit this form (admin/shipping_methods/new), there are no shipping calculators available under the Calculator drop down. From the documentation, Spree ships with 5 calculators by default, yet there are none available.
I am using Spree 2-4-stable. I have browsed the repo and sure enough, the calculators are there. I have also researched the controller to see where the call is made to build the calculator array. The code within the controller is:
...
#calculators = ShippingMethod.calculators.sort_by(&:name)
...
This returns an empty array, hence why no calculators are showing up.
I have tried to pull a list of calculators myself in other areas with no luck.
# Returns an empty array as well
#calculators = Spree::ShippingMethod.calculators
The odd thing is, if I run rails console within my directory and once initialized run
# Returns the 5 default calculators
calculators = Spree::ShippingMethod.calculators
Naturally, I am confused. Does rails console pull from a different source? How is it I can pull the data from the console, but not the application. No errors, just an empty array from within the application.
This prevents me from adding a shipping method, which prevents me from completing my setup.
Any thoughts?
I would consider this more of a hack than an "answer", but either way, it's a solution.
I finally decided to just create my own Shipping Calculator by simply cloning one of the Spree defaults and renaming it. I followed the documentation for creating a custom Shipping Calculator. Once I copied the class and renamed, I added it via the config methods stated.
Upon adding the config statement, all of the default shipping calculators started to appear! As if to create another bug, my custom calculator was no where to be found however. I decided to remove the config line adding my calculator, but left the initial config line which kept the default calculators working.
So, while I am sure this is a bug of some sort, the solution was to add the following line at the bottom of config/initializers/spree.rb
config = Rails.application.config
Restarted the server and boom! Calculators available for selection now.
UPDATE:
Just to test, I removed the config line from the file and deleted my custom Shipping Calculator from the directory to see if it would break the Shipping Calculators again. Oddly enough, they still work. Perhaps loading the config using the method above saved a state in the system allowing it to continue functioning.
Either way, I hope someone else out there can provide some light on the issue.

Get uRapidFlow logs for an import profile batch

I am running a php script using a cron job to run a uRapidFlow / RapidFlow import profile. Here is the documented code I found to help me do this.
I need to be able to run through the imported batch, row by row, and do some processing based on if the row was imported successfully or not. It would also be very convenient and useful to be able to send email notifications on failed imports in general as well. If anyone has any idea, or can point me in the right direction, I would be very grateful. I don't see any documentation for this online, so I am going through the module code and database trying to figure it out myself.
I am using Magento EE 1.12.0.2
The best bet, unless you modify the uRapidFlow extension (check license information before doing so). Would be to extend it and use a observed event.
Try the observer : catalog_product_import_finish_before Which is triggered after each product is imported. Bare in mind this solution would be triggered globably for any manual imports, so if you build a small extension, perhaps make it easy to toggle on and off.
More can be found on Magento's observers here : http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
Note as you've not specified which version of Magento you are using, you'll have to check if that observer is supported in your version.

Magento - Mage::getModel not working on Linux server

I'm struggling with an issue for which I can't find an explanation. I have two development environments that I use for my projects. I created a simple module for Magento and I tested it on one environment. After overcoming all Magento's complications, the module works as expected. This is on XAMPP.
I then copied the module to the development Linux environment, on a hosted server, and it crashes miserably. I did some debugging, and I found out that a call to Mage::getModel() returns bool(false) instead of the instance of the Model I requested.
I double checked all files and directories, and they match. Database is not involved (not from my side, at least, I don't need tables) and both environments have only me as a User, with Admin permissions.
Any suggestion on where should I start looking is welcome, thanks.
Added on 2012/07/09
Model contains a class named Diego_ClientCustomModule_Model_ExternalUserData, which is invoked with $model = Mage::getModel('clientcustommodule/externaluserdata');. Model file resides in Diego_ClientCustomModule\code\local\Diego\ClientCustomModule\Model\. The curious thing is:
If model file is named Externaluserdata.php, it works.
If model file is named ExternalUserData.php (i.e. it matches the class name), it doesn't work.
I'm aware of case sensitivity stuff etc, but, if the alias is all lower-case, how comes it can load a file having the first letter capitalized?
Configuration file
0.1.0
Diego_ClientCustomModule_Helper
Diego_ClientCustomModule_Model
Diego_ClientCustomModule_Block
standard
Diego_ClientCustomModule
ClientCustomModule
Snarking about the framework for which you are asking for help may not be the best strategy for receiving help.
Your issue is likely one of cache (remove var/cache folder to check) or one of improper casing. Note that the first letter of each directory and filename for files loaded by the autoloader (blocks, models, and helpers).
It seems I have found the root cause of the issue, although I can't figure out what kind of logic has been implemented to make it happen.
Model's file name was UserCustomModule.php, which reflected the class name UserCustomModule. That made sense, and worked wonderfully in XAMPP. Once I installed the same module on a Linux box, Magento silently ignored the file and, as previously stated, there's been no way to track down Magento's actions.
Following benmark suggestion, I went through all the files again to check the casing, and everything seemed to match. I then made something, in my opinion, completely stupid, and I renamed the Model file to Usercustommodule.php, leaving the class name untouched (after all, PHP should behave the same on both platforms, unlike the file system). Magically, the module now works! The file name looks cr*p, but it works.
This solved the problem, yet it raises more questions:
For what reason Magento has troubles loading a file with a CamelCase name? If it's Autoloading, it should simply find a file and load it. After all, it loads the Controller, the Block and everything else, and they are all in CamelCase.
Is it written anywhere that one or more files must have only the first letter capitalized? I got enough surprises already, I'd like to avoid new ones, if possible.
Thanks again for the help.

How to trace CakePHP's inner workflow

Short description
I'm getting used to CakePHP right now and am wondering about how to get more debug-information about what is happening inside the framework.
Let me please explain my situation a little more detailed
As you know CakePHP does a lot for you without putting you into the need to write additional code. One example is the handling of models.
I just created a model User and added validation-rules (no other methods). As described in the API methods like save will just work.
After that I created the needed controller and view to add a new user. When I try to add a user from the view I just receive the flash-message The user could not be created. Please, try again. No validation-violations are flashed.
I also did set the debug-level to 2: Configure::write('debug', 2); but do not receive any errors. The error.log inside \tmp\logs is also empty.
I really do want to learn how to solve those issues in the future.
So what else can I do to debug / display inner processes of cake?
Thank you very much for your help!
DebugKit is an official plugin that gives you lots of information on the request, queries and variables produced by Cake:
https://github.com/cakephp/debug_kit
You can also use trace() and other methods in the Debugger to show what is being executed in the background:
http://book.cakephp.org/2.0/en/development/debugging.html
Use a PHP IDE with an integrated debugger. That will allow you to follow execution line by line as it is executed and even inspect variable values as you go. Netbeans is a free one.

Resources