Open f1-outsourcing opened 3 years ago
i don't think this is an issue caused by openmage
Could be caused by the emulation, analog to how the translations work during email sending. Can you get a full backtrace for this case?
Hmmm, I hope this is what you mean, I am not really a magento developer.
I added this
echo Varien_Debug::backtrace(true, true);
exit;
And it generated this:
#1 F1outsourcing_EmailTemplatesTheme_Model_Translate#000000001bbcf7ec00000000679e3f78#->getTemplateFile('sales/order_new_...', 'email', 'en_GB') called at [app/code/core/Mage/Core/Model/Email/Template.php:183]
#2 Mage_Core_Model_Email_Template#000000001bbcf7a800000000679e3f78#->loadDefault('sales_email_orde...', 'en_GB') called at [app/code/core/Mage/Core/Model/Email/Template.php:507]
#3 Mage_Core_Model_Email_Template#000000001bbcf7a800000000679e3f78#->sendTransactional('sales_email_orde...', 'sales', array('asdfa@asdfadfs.c...'), array('dasdfasdf asdfad...'), array('order' => &Mage_Sales_Model_Order#000000001bbcf6f400000000679e3f78#, 'total' => '€1.00', 'billing' => &Mage_Sales_Model_Order_Address#000000001bbcf7d300000000679e3f78#, 'payment_html' => '
Bank Transfer...'), 2) called at [app/code/core/Mage/Core/Model/Email/Template/Mailer.php:83]
#4 Mage_Core_Model_Email_Template_Mailer#000000001bbcf7d700000000679e3f78#->send() called at [app/code/core/Mage/Sales/Model/Order.php:1461]
#5 Mage_Sales_Model_Order#000000001bbcf6f400000000679e3f78#->queueNewOrderEmail(true) called at [app/code/core/Mage/Sales/Model/Order.php:1476]
#6 Mage_Sales_Model_Order#000000001bbcf6f400000000679e3f78#->sendNewOrderEmail() called at [app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php:141]
#7 Mage_Adminhtml_Sales_OrderController#000000001bbcf6f300000000679e3f78#->emailAction() called at [app/code/core/Mage/Core/Controller/Varien/Action.php:437]
#8 Mage_Adminhtml_Sales_OrderController[Mage_Core_Controller_Varien_Action]#000000001bbcf6f300000000679e3f78#->dispatch('email') called at [app/code/core/Mage/Core/Controller/Varien/Router/Standard.php:262]
#9 Mage_Core_Controller_Varien_Router_Admin[Mage_Core_Controller_Varien_Router_Standard]#000000001bbcf6f900000000679e3f78#->match(&Mage_Core_Controller_Request_Http#000000001bbcf6c200000000679e3f78#) called at [app/code/core/Mage/Core/Controller/Varien/Front.php:192]
#10 Mage_Core_Controller_Varien_Front#000000001bbcf6fc00000000679e3f78#->dispatch() called at [app/code/core/Mage/Core/Model/App.php:381]
#11 Mage_Core_Model_App#000000001bbcf6e300000000679e3f78#->run(array('scope_code' => '', 'scope_type' => 'store', 'options' => array())) called at [app/Mage.php:744]
#12 Mage::run('', 'store') called at [index.php:88]
From a logical point of view it is just strange to me, that template files are gotten from different locations when you click the 'send email' button on a order in the admin.
Can something be done about this, or can someone explain me a work-a-round? I am going to put one shop online soon (I hope). But it would be nice if I start using a 2nd template, I can get different email templates for that. I would say even it is nice to have by default the email templates in the theme tree. But maybe that is also due to a lack of expert experience, wanting such a thing.
@Flyingmana anything new on this?
I just dug into this for some time, and I found that indeed the emulation is the culprit here because it ends before the templates are loaded. It's not really a problem currently because by default they don't depend on theme so... I'll see.
@elidrissidev
Hi Mohamed, thanks for looking into this. Do you have a temporary fix for this? I still do not have my store online for what I was planning to use it. But something else came up and thought about using the current magento for it. But I need to have this working, otherwise I need to create separate install. I am willing to financially contribute ;)
@f1-outsourcing If memory serves me right, it should be as easy as updating/overriding the core file and making template loading happen when the store is still being emulated. I'll recheck in a few hours.
Briefly checked, wrapping the line below with the two method calls should make it work, however there could be a better solution.
Wrap it like this:
+ $this->_applyDesignConfig();
$templateText = Mage::app()->getTranslator()->getTemplateFile(
$data['file'],
'email',
$locale
);
+ $this->_cancelDesignConfig();
Instead of modifying the core you can rewrite the file using your custom extension, or override it fully by copying it to app/code/local/Mage/Core/Model/Email/Template.php
and then applying the changes.
@elidrissidev
Thanks! Much appreciated :) I think this works, I have to test a bit more. I looked at it such a long time ago.
When testing with a module to override the location where email templates are stored (want to keep them within the theme tree) I noticed that files are gotten from different locations.
This is code that compiles the path
This is being logged to system.log when I choose 'send email' on a order in the admin menu.
The module is working correctly otherwise there would be no logging however the order_new.html is grabbed still from 'frontend/default/default' while the header.html/footer.html are grabbed from the correct location '/rwd/customname'
I am not familiar with magento internals, but I would assume this is an inconsistency how files are gotten. maybe some environment is not set when the order_new.html is requested?
Preconditions (*)
git clone 1.9.4.x
Steps to reproduce (*)
1. 2.
Expected result (*)
Actual result (*)