store wise email not working magento 1.5 - magento

I have 5 different store in my website. My default store is English,
1) when someone registered from english store he get currect email in English language
2) when someone registered from german store he also get email in English language instead of german language.
Any idea for solving this issues.
Thanks,
Hardik

Finally i got the solution for new customer registration emails.
Mage/Customer/Model/Customer.php
in this file i have make some changes as following.
find this line of code
if (!$storeId)
{
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
and replace with
$storeId = ($storeId == '0')?$this->getSendemailStoreId():$storeId;
if ($this->getWebsiteId() != '0' && $storeId == '0')
{
$storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
reset($storeIds);
$storeId = current($storeIds);
}
Thanks,

Related

Force to load another store with different currency [Magento 1.7]

I have created module that checks user country based on his IP and now I want to force users from Europe load website_en with store id 2 and US users to load website_us with store id 1.
In index.php I have tried to do:
<?php
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
if (in_country() == "EU") {
Mage::run("website_en ", "store");
}
else if(in_country() == "US")
{
Mage::run("website_us ", "store");
}
else
{
Mage::run($mageRunCode, $mageRunType);
}
...but without any luck.
Thanks I have solved this problem by properly configuring varnish.
Actually this code is working. website is with differents domains.
in_country - is code that check users geo info.

Magento "Forgot Password" email sent in wrong language

I have a Magento site with multiple languages. I have setup the language packs and everything seems to translate properly on the website. Also the transactional e-mails are sent in the correct language EXCEPT for the "Forgot Password" e-mail which is always sent in German. Here's what I did:
Installed language packs and made sure all templates and folder structures are correct. Example: /app/locale/nl_NL/template/email/
Under System » Transactional Emails: I applied the template, chose the locale and saved.
Then I went to System » Configuration » Sales Emails, I switched to each language from the "Current Configuration Scope" dropdown, and I chose the templates I created in Transactional Emails for each language (each store view).
After looking around online for a solution, it seems others had this problem too and someone mentioned that Magento is picking the "Forgot Password" template from the first locale folder found in /app/locale/. In my case I had: de_DE, en_US, fr_FR, nl_NL. So It picks the template from the German de_DE pack.
NOTE: Also, in the backend under "Configuration" there's a tab on the left called "LOCALE PACKS" which only has "Locale de_DE" under it, even though I have other language packs which don't show up here. Not sure if this is relevant.
Site: http://site1.cp1.glimworm.com/magento/
Magento Community version: 1.7.0.2
Locale packs:
Mage_Locale_en_US
Locale_Mage_community_de_DE
Locale_Mage_community_fr_FR
Mage_Locale_nl_NL
Any idea how I can get the correct email template from the corresponding language to be sent as opposed to always German? Any help will be greatly appreciated! I can provide more info as well.
I have same problem in magento v1.5. After a long research i found this solution and its working for me.
Mage/Customer/Model/Customer.php
in this file i have make some changes as following.
find this line of code
if (!$storeId)
{
$storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
}
and replace with
$storeId = ($storeId == '0')?$this->getSendemailStoreId():$storeId;
if ($this->getWebsiteId() != '0' && $storeId == '0')
{
$storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
reset($storeIds);
$storeId = current($storeIds);
}
I had the same problem, and it looks like user2282917's solution works with a little modify:
You should edit the sendPasswordResetConfirmationEmail function in the Customer.php not the sendNewAccountEmail. Try to replace the code there, and it will working.
Overwrite the forgotPasswordPostAction controller on the AccountController.php.
You need to set the correct store id so that the locale will be used.
/**
* Forgot customer password action
*/
public function forgotPasswordPostAction()
{
$email = (string) $this->getRequest()->getPost('email');
if ($email) {
if (!Zend_Validate::is($email, 'EmailAddress')) {
$this->_getSession()->setForgottenEmail($email);
$this->_getSession()->addError($this->__('Invalid email address.'));
$this->_redirect('*/*/forgotpassword');
return;
}
/** #var $customer Mage_Customer_Model_Customer */
$customer = $this->_getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
->loadByEmail($email);
if ($customer->getId()) {
try {
$newResetPasswordLinkToken = $this->_getHelper('customer')->generateResetPasswordLinkToken();
$customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
// Add store ID so that correct locale will be set
$customer->setStoreId(Mage::app()->getStore()->getId());
$customer->sendPasswordResetConfirmationEmail();
} catch (Exception $exception) {
$this->_getSession()->addError($exception->getMessage());
$this->_redirect('*/*/forgotpassword');
return;
}
}
$this->_getSession()
->addSuccess( $this->_getHelper('customer')
->__('If there is an account associated with %s you will receive an email with a link to reset your password.',
$this->_getHelper('customer')->escapeHtml($email)));
$this->_redirect('*/*/');
return;
} else {
$this->_getSession()->addError($this->__('Please enter your email.'));
$this->_redirect('*/*/forgotpassword');
return;
}
}
In the below file
Mage/Customer/Model/Customer.php
In sendPasswordResetConfirmationEmail function() change the
$storeId = $this->getStoreId();
to
$storeId = Mage::app()->getStore()->getStoreId();
Thanks
In our case... We found that when a Customer Account was created by Admin the "email send from" option was not saved and only used for the first account creation email. Any subsequent email sent are sent from the default store view of the website the customer was allocated.
The real problem is how, when the customer store id is identified when none is set.
The method sendPasswordResetConfirmationEmail (Magento 1.9.1) when the store id is 0 (admin or not set), defaults to _getWebsiteStoreId which will return the first store id associated to that website.
The problem is that Magento assumes the first store id associated with the website id is the default store... We found this is not the case when a Sort Order is set against the store record.
Simply put make sure your default store assocaited with a web site is also specified with a sort order of 0.
Hope this link will be usefull to you
In link they have used New Password but Instead of New Password Use Forgot Password template In step 4
Thanks..
The password reset email is send in Mage_Customer_Model_Customer::_sendEmailTemplate(). Here the emailtemplate is loaded. If it was loaded in admin in "Systemn > Transactional Emails" and configured to be used, your template will be used.
Else the default template is loaded from file in Mage_Core_Model_Email_Template::sendTransactional. This is done using $this->loadDefault($templateId, $localeCode); The template ist loaded using
$templateText = Mage::app()->getTranslator()->getTemplateFile(
$data['file'], 'email', $locale
);
Here locale folders are checked in following order:
Specified locale
Locale of default store
en_US locale
The first matched locale is chosen. As Mage::app() doesn't know about the store which was passed with the emailtemplate, the default defaultstore is loaded, which is german in your case. It has nothing to do with the order of the locale folders.
So in your case I suggest to check if your emailtemplate is selected in admin configuration in "System > Config > Customerconfiguration > Password Options" or use Mage::getStoreConfig(Mage_Customer_Model_Customer::XML_PATH_REMIND_EMAIL_TEMPLATE, $storeId) if it is set for your store.
The reason for why you are receiving the email templates in another language than the one expected is dependent of the language in which you first created your account. Try to check this to be in your own language when you first created the account.
Check this under Customers> Account Information to see how your account was created.
/Kalif

Wp E commerce product variation price from external csv file

The e commerce site I am working on needed the prices to be updated from a CSV file. the file has two fields : Price and SKU. On the product page I have inserted the following code so that the price is displayed according to the SKU. (It might look crude, but that is the my php level)
<?php
$mysku = wpsc_product_sku(wpsc_the_product_id());
$data = 'path to the csv file.csv' ; //Obvious
$pricelist = array();
if (($handle = fopen($data, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$pricelist[$data[3]] = $data[0];
$pricecaption = "Price" ;
}
fclose($handle);
}
$myprice = $pricelist[$mysku];
if (!$myprice == ' ') {
echo " " ;
}else {
echo $pricecaption." : " .$myprice.".00" ;
}
?>
This replaces the prices on the product pages. The issue is with the single product page. There you have variations. So when you select a variation from the drop down, it just shows the price from the database.
I understood that the Ajax request is bringing the variation prices from the database. But I have no clue how to prevent that from happening and show the price according to the seleced variation's SKU.
Any help will be appreciated. I think the work has to be done on wpsc_update_product_price() function in ajax.functions.php
Thank you all in advance!
try to use to this hook: add_action( 'wpsc_update_variation_product', 'yourFunction') in your themes functions.php and edit the variations to manipulate the later steps of wpsc_update_product_price
But I don't understand why you cannot import the CSV to wpsc to use the original features of the shop...?

Get customer in Mage_Tax_Model_Calculation::getRate in magento

I have overwritten the Mage_Tax_model_Calculation::getRate, so that I want to not tax certain customers. I do not have a special customer class for them.
I have a custom field in my customer model, which I want to check after I am able to load my customer model and if this field has a value I do not tax him, otherwise I call parent::getRate($request)
Is it possible to get that in the function.
Try something like this:
function getRate($request) {
// find a customer ID
$admin_session = Mage::getSingleton('adminhtml/session_quote');
if($admin_session) {
if($admin_session->getCustomerId()) {
$customer_id = $admin_session->getCustomerId();
}
} else {
$customer_id = Mage::getSingleton("customer/session")->getCustomerId();
}
// find customer attr
if($customer_id) {
$customer = Mage::getModel("customer/customer")->load($customer_id);
if($customer->getSomeColumnValue()) {
return 0;
}
}
// fallthrough
return parent::getRate($request);
}
Hope that helps!
Thanks,
Joe
EDIT: good point ;)
Looking through the adminhtml code, it seems to be far less useful than the normal customer code. I was hoping for a call to Mage::register but that's not happening. I found a possible solution, though loading sessions in Magento seems to have side effects. See above.
RE-EDIT: to incorporate your fixes for posterity.
Try this to load the current logged-in customer:
$session = Mage::getSingleton('customer/session');
$customer = Mage::getModel('customer/customer')->load($session->getCustomerId());
$customValue = $customer->getCustomFieldName();
Cheers,
JD

Magento 1.4 paypal bug

i try to get the paypal payment run in my magento 1.4 but there is a serious problem with the workflow. after i select paypal and get routed to the paypal account to send the money you normally come back automatically into the magento shop to finish the order, but in my case magento tells you there is aproblem with the adress field. paypal does'nt send the adress back to magento correctly:
Error: Please check shipping address information. Please enter last name.
is this a known bug or is there a patch or workaround?
please help!
thnx.
The error seems to be in /app/code/core/Mage/Paypal/Model/Api/Nvp.php. Looks like the vars aren't mapped well. Because I couldn't find the concrete error in this file, I did a bit dirty workaround in /app/code/core/Mage/Paypal/Model/Express/Checkout.php.
In 1.4.2 just replace the method returnFromPaypal() with the following code...
public function returnFromPaypal($token)
{
$this->_getApi();
$this->_api->setToken($token)
->callGetExpressCheckoutDetails();
// import billing address
$billingAddress = $this->_quote->getBillingAddress();
$exportedBillingAddress = $this->_api->getExportedBillingAddress();
// import shipping address
$exportedShippingAddress = $this->_api->getExportedShippingAddress();
if (!$this->_quote->getIsVirtual()) {
$shippingAddress = $this->_quote->getShippingAddress();
if ($shippingAddress) {
if ($exportedShippingAddress) {
foreach ($exportedShippingAddress->getExportedKeys() as $key) {
if('firstname' == $key || 'lastname' == $key){
continue;
} // if
$shippingAddress->setDataUsingMethod($key, $exportedShippingAddress->getData($key));
$billingAddress->setDataUsingMethod($key, $exportedShippingAddress->getData($key));
}
// Correct First- and Lastnames
list($_firstname, $_lastname) = explode(' ', $exportedShippingAddress->getData('firstname'));
$shippingAddress->setDataUsingMethod('firstname', $_firstname);
$billingAddress->setDataUsingMethod('firstname', $_firstname);
$shippingAddress->setDataUsingMethod('lastname', $_lastname);
$billingAddress->setDataUsingMethod('lastname', $_lastname);
$shippingAddress->setCollectShippingRates(true);
}
// import shipping method
$code = '';
if ($this->_api->getShippingRateCode()) {
if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) {
// possible bug of double collecting rates :-/
$shippingAddress->setShippingMethod($code)->setCollectShippingRates(true);
}
}
$this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD, $code);
}
}
$this->_ignoreAddressValidation();
// import payment info
$payment = $this->_quote->getPayment();
$payment->setMethod($this->_methodType);
Mage::getSingleton('paypal/info')->importToPayment($this->_api, $payment);
$payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_api->getPayerId())
->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token)
;
$this->_quote->collectTotals()->save();
}
The modified code replaces the whole billing address with the shipping address and pushes the name given in $firstname into $firstname and $lastname.
not clean, but working. :-)
any luck finding a solution to this, I'm having the same issue.
--- update ---
I finally figured out what was happening on this one for me. I had the Custom Shipping Admin module installed and it was overriding the address controller that validates the order. I updated the overrided module to reflect the version of Magento I was on and it worked.. no problems. Hope this helps someone.

Resources