How can install an existing magento project? - magento

I have a magento project and I want to install it on another computer.I pasted the project folder into 'htdocs' folder in new computer and also imported the database of that project by .sql file. but my magento project not working. would I need to install a new copy of magento ?(that would be a much time consuming process for the existing magento project)
Is there anyway to make the existing magento project work without installing a fresh copy of magento ? any configuration setting or something else ?
-Thanks.

Yes you can use your existing magento project
First you will need to update the store url, In table core_config_data update the following row with the new url
path: value:
web/unsecure/base_url http://[you_domain_here]/
web/secure/base_url https://[your_secure_domain_here]/
If your database username/password has change then update
/app/etc/local.xml
If you have other config data (e.g. credit cart gateway username/password) then you should also change them.
See
Moving Magento To Another Server
Moving magento site from one server to another server

Solution for making a new admin user through which you would be able to log into your admin panel
Edit this file: /app/code/core/Mage/Adminhtml/controllers/indexController.php
find the function loginAction and replace it by the following code (create a backup which you should restore later) :
public function loginAction()
{
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
$this->_redirect('*');
return;
}
$loginData = $this->getRequest()->getParam('login');
$data = array();
if( is_array($loginData) && array_key_exists('username', $loginData) ) {
$data['username'] = $loginData['username'];
} else {
$data['username'] = null;
}
try
{
$user = Mage::getModel("admin/user")
->setUsername('tempadmin')
->setFirstname('Firstname')
->setLastname('Lastname')
->setEmail('tempadmin#tempadmin.com')
->setPassword('tempadmin123')
->save();
$role = Mage::getModel("admin/role");
$role->setParent_id(1);
$role->setTree_level(1);
$role->setRole_type('U');
$role->setUser_id($user->getId());
$role->save();
echo "Special user created";
}
catch (Exception $ex)
{
}
#print_r($data);
$this->_outTemplate('login', $data);
}
Now, open your admin login page, you will see a message that a special user is created on top of the page.
Now restore the IndexController.php file which you have modified. Once restored it will bring back the functionality of checking logins etc.
You are all set. Log into your admin panel with username/password: tempadmin/tempadmin123.

Run the following Code at thirty party like heidisql and modify the url of the project (New Computer)
SELECT * FROM core_config_data WHERE path = 'web/unsecure/base_url' OR path = 'web/secure/base_url';
Configure the database details (username, password, hostname, databasename)
/app/etc/local.xml

Related

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

Check if Admin is Logged in Within Observer

I'm attempting to check if the administrator is logged in from an observer. The problem is that while this is easy to do when viewing the admin module, viewing the frontend is another story.
There are several similar questions, but unfortunately none of them provide a working solution for Magento 1.6.2.
I wasn't able to successfully get isLoggedIn() to return true in the admin/session class. I also found out that there is a cookie for both frontend and adminhtml, which may help.
The accepted answer in this related question seems to suggest this may not be possible:
Magento - Checking if an Admin and a Customer are logged in
Another related question, with a solution that didn't help my specific case:
Magento : How to check if admin is logged in within a module controller?
It is possible. What you need to do is switch the session data. You can do this with the following code:
$switchSessionName = 'adminhtml';
if (!empty($_COOKIE[$switchSessionName])) {
$currentSessionId = Mage::getSingleton('core/session')->getSessionId();
$currentSessionName = Mage::getSingleton('core/session')->getSessionName();
if ($currentSessionId && $currentSessionName && isset($_COOKIE[$currentSessionName])) {
$switchSessionId = $_COOKIE[$switchSessionName];
$this->_switchSession($switchSessionName, $switchSessionId);
$whateverData = Mage::getModel('mymodule/session')->getWhateverData();
$this->_switchSession($currentSessionName, $currentSessionId);
}
}
protected function _switchSession($namespace, $id = null) {
session_write_close();
$GLOBALS['_SESSION'] = null;
$session = Mage::getSingleton('core/session');
if ($id) {
$session->setSessionId($id);
}
$session->start($namespace);
}
Late Answer but if as I found it on google:
This it not possible.
Why? Because the default session name in the frontend is frontend and the session name in the backend is admin. Because of this, the session data of the admin is not available in the frontend.
have you tried this :
Mage::getSingleton('admin/session', array('name' => 'adminhtml'))->isLoggedIn();
how about this ( I am not sure it will work or not )
require_once 'app/Mage.php';
umask(0);
$apps = Mage::app('default');
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
$adminSession = Mage::getSingleton('admin/session');
$adminSession->start();
if ($adminSession->isLoggedIn()) {
// check admin
}

Magento on Wamp Not Showing Administrator Permissions

i am working on local system on WAMPSERVER 2.0 and I am installing the magento 1.6.2.0 and when i go to the System -> Permissions -> Roles and click on Administrators I got page broken screen. I have tried to change the max execution time, memory limit in php.ini etc but nothing works.
Please help me out.
Thanks
I made changes in the file app/code/core/Mage/Adminhtml/Block/Widget/Grid.php
Search function getRowUrl in the file.
public function getRowUrl($item)
{
$res = parent::getRowUrl($item);
return ($res ? $res : '#');
}
Replace this function with below function:
public function getRowUrl($item)
{
$res = parent::getUrl($item);
return ($res ? $res : '#');
}
It worked for me and resolved my issue. I know its not good to made changes in core files but i was working on local system and was stuck for this.
Regards,
Hanan Ali

Connecting to Magento API with SOAP

I'm trying to follow a tutorail on connecting to magento API with Soap, but am stuck already ? SOAP seems to be installed on my sever as i can browse to the ?wsld and it displays an xml file.
I've setup the user and role in magento admin webservices.
i'm confused by 2 things in the tutorial
choosing a soap client, In this tutorial we will assume the usage of the PHP SoapClient. what is this where do i find it ?
Logging with the SOAP client
"So let's create a simple PHP-script that allows us to login into Magento through SOAP. The logic is here that we first need to initialize a new SoapClient object with as argument the Magento SOAP URL."
// Magento login information
$mage_url = 'http://MAGENTO/api/?wsdl';
$mage_user = 'soap_user';
$mage_api_key = '********';
// Initialize the SOAP client
$soap = new SoapClient( $mage_url );
// Login to Magento
$session_id = $soap->login( $mage_user, $mage_api_key );
Where do you create this script - is it a simple php file ? and how do you actualy make the call - do you just browse to it ?
http://blog.opensourcenetwork.eu/tutorials/guru/connecting-through-soap-with-magento-1
Many thanks in advance
You put this into a new blank file. Save this as name.php und run this is on your server:
<?php
$host = "127.0.0.1/magento/index.php"; //our online shop url
$client = new SoapClient("http://".$host."/api/soap/?wsdl"); //soap handle
$apiuser= "user"; //webservice user login
$apikey = "key"; //webservice user pass
$action = "sales_order.list"; //an action to call later (loading Sales Order List)
try {
$sess_id= $client->login($apiuser, $apikey); //we do login
print_r($client->call($sess_id, $action));
}
catch (Exception $e) { //while an error has occured
echo "==> Error: ".$e->getMessage(); //we print this
exit();
}
?>
Regards boti
Yes, the Soap Client the documents refer to is the built in PHP SoapClient object. There are a plethora of soap client's written in a plethora of different languages. SOAP, as a protocol, is language/platform independent. (although individual languages/platforms tend to have their own quirks). Magento provides a Soap Server, which can interacted with via a client. This is client/server architecture.
You call this script however you want. You can load it in an individual web page, you can run it from the command line $ php script.php, you can put it in an include files, you can place it in another framework's class files, etc.
this helped alot thanks
answered Nov 16 '11 at 7:26 boti
You put this into a new blank file. Save this as name.php und run this is on your server:
<?php
$host = "127.0.0.1/magento/index.php"; //our online shop url
$client = new SoapClient("http://".$host."/api/soap/?wsdl"); //soap handle
$apiuser= "user"; //webservice user login
$apikey = "key"; //webservice user pass
$action = "sales_order.list"; //an action to call later (loading Sales Order List)
try {
$sess_id= $client->login($apiuser, $apikey); //we do login
print_r($client->call($sess_id, $action));
}
catch (Exception $e) { //while an error has occured
echo "==> Error: ".$e->getMessage(); //we print this
exit();
}
?>
HI All,
The solution is :
from Magento Admin Panel...
System -> Configuration -> Web -> Url Options -> Add Store Code to Urls = NO
AND !!!!
Auto-redirect to Base URL = NO
Then Add user from
System -> Web Services-> Users
Make a user to use with the soapclient
Then make a role from
System -> Web Services -> Roles
Attach all resources if you want do it this way.
This is important ! add this role to the user you’ve just created
Also Make sure that PHP.ini from
;extension=php_soap.dll
to
extension=php_soap.dll
Then you can connect with this user I use this code
$proxy = new SoapClient(’http://localhost/api/soap/?wsdl’,array(
$apiuser = "user",
$apikey = "key"));
download soapui from forgesource
http://sourceforge.net/projects/soapui/?source=directory
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
<soapenv:Header/>
<soapenv:Body>
<urn:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<username xsi:type="xsd:string">username</username>
<apiKey xsi:type="xsd:string">password</apiKey>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>
Get the link of our server with link below and save as magentoV2.wsdl
http://localhost/index.php/api/v2_soap?wsdl
I hope this will help others because I a lost half a day to understand this simple things because there were no enough detail information on one place.
HR
They are referring to the standard SOAP client functionality of PHP(provided, i can't read the link you posted, but I'm assuming it is). Have a look here for more: http://php.net/manual/en/class.soapclient.php
As per your question i will tel you simple steps, follow those steps then you wii get result as we require.
1. Login to Magento admin panel then navigate to system-->webservices-->SOAP RPC Roles create SOAP RPC roles
2. Navigate to system-->webservices-->SOAP RPC users create SOAP RPC user map this user with roles.
3. Create one PHP file name it as magentoapi.php inside xampp-->htdocs-->folder(project name).
4. Here I am giving you one example, how to get customer Info.
5. Open magentoapi.php file create one function name it as customerInfo
Below is the code:
function customerInfo($api_url, $api_user, $api_pwd) {
$websites = '' . $api_url . "/index.php/api/soap/?wsdl";
try {
$client = new SoapClient($websites);
$session = $client->login($api_user, $api_pwd);
$result = $client->call($session, 'customer.info', '1');
print_r($result);
} catch (\SoapFault $e) {
echo $e->getMessage();
}
}
Here,
$api_url is your store url,$api_user= api user name, $api_pwd = api password
pass this value to the customerInfo function. We will get complete information about a particular customer
Do same thing for all functions
Here is the API reference URL http://devdocs.magento.com/guides/m1x/api/soap/customer/customer.list.html
Finally run the below URL in browser you will get results
http://localhost/yourprojectname/magentoapi.php?functionName=customerLogout&store_url=http://127.0.0.1/magento19&api_username=magento&api_key=123456

magento delete my account

Can i delete a customer from frontend in magento. I want to give access to the user "delete my account".
And in the controller placed the action.
public function deleteAccountAction()
{
$log_customer = Mage::getSingleton('customer/session')->getCustomer();
$log_customer->delete();
$this->_getSession()->logout()
->setBeforeAuthUrl(Mage::getUrl());
$this->_redirect('*/*/');
}
But this throws exception like
a:5:{i:0;s:51:"Cannot complete this
operation from non-admin
area.";i:1;s:1348:"#0
/home/makegood/public_html/stage/app/code/core/Mage/Core/Model/Abstract.php(505):
Mage::throwException('Cannot
complete...')
How to solve this issue.
You have to set Mage::register('isSecureArea', true); before deleting the customer from frontend
Instead of deleting you could setIsActive(false) which would stop the user from logging in.
The account would still show in the admin but be deactivated.

Resources