Monday, April 23, 2012

How to Create different store view with different sub-domain in magento

How to create store view


1. Go to admin then select tab System->manage stores
2.Click create store view and complete the form and save store view
then you will be able to see in the list.

How to Change the Base URL for each Store view


1.. Go to admin then select tab System->configuration
2.On the left side of the page General under that select web but before that you have to change the Current Configuration Scope to your store view name
3. Edit the base url to you subdomain(eg: http://en.yourdomain.com)
4.click save config.

How to change .htaccess for redirecting to store view if you call the subdomain


1.Your .htaccess file is at the root folder of magento.
2.Search for "RewriteEngine on" word  in .htaccess file and write the code below it

RewriteCond %{HTTP_HOST} ^en.yourdomain.com
RewriteRule ^ - [E=MAGE_RUN_CODE:english]
RewriteCond %{HTTP_HOST} ^fr. yourdomain .com
RewriteRule ^ - [E=MAGE_RUN_CODE:french]

 then save the .htaccess file and try to clear all cache and browsing history from your browser as well as from magento

Tuesday, February 14, 2012

magento the shipment email is not sent


Solution Works For Me
Go to -> Mage_Sales_Model_Order_Shipment and copy the file Api.php
Make a path like this in local folder app/code/local/Mage/Sales/Model/Order/Shipment
Edit Api.php 
In function Create comment the sendEmail function call
try { 
$transactionSave = Mage::getModel(’core/resource_transaction’) 
->addObject($shipment) 
->addObject($shipment->getOrder()) 
->save(); 
/*$shipment->sendEmail($email, ($includeComment ? $comment : ‘’));*/ 
} catch (Mage_Core_Exception $e) { 
$this->_fault(’data_invalid’, $e->getMessage()); 
} 
In function addTrack add function call sendEmail
try { 

$shipment->save(); 
$track->save(); 
$email=true; 
$shipment->sendEmail($email,’’); 
} catch (Mage_Core_Exception $e) { 
$this->_fault(’data_invalid’, $e->getMessage()); 
}
Now you Shipment Email will be send as usual email with tracking number

Friday, February 3, 2012

PHP Mailing by attaching a file

<?php
  $to = "some mail@mymail.com";
  $subject = "New Product Details";
  $message = "New product be find in attachment.";
  # Open a file
  $file = fopen( "product.txt", "r" );
  if( $file == false )
  {
     echo "Error in opening file";
     exit();
  }
  # Read the file into a variable
  $size = filesize("product.txt");
  $content = fread( $file, $size);
  # encode the data for safe transit
  # and insert \r\n after every 76 chars.
  $encoded_content = chunk_split( base64_encode($content));
 
  # Get a random 32 bit number using time() as seed.
  $num = md5( time() );
  # Define the main headers.
  $header = "From:admin@magento-works.com\r\n";
  $header .= "MIME-Version: 1.0\r\n";
  $header .= "Content-Type: multipart/mixed; ";
  $header .= "boundary=$num\r\n";
  $header .= "--$num\r\n";
  # Define the message section
  $header .= "Content-Type: text/plain\r\n";
  $header .= "Content-Transfer-Encoding:8bit\r\n\n";
  $header .= "$message\r\n";
  $header .= "--$num\r\n";
  # Define the attachment section
  $header .= "Content-Type:  multipart/mixed; ";
  $header .= "name=\"test.txt\"\r\n";
  $header .= "Content-Transfer-Encoding:base64\r\n";
  $header .= "Content-Disposition:attachment; ";
  $header .= "filename=\"product.txt\"\r\n\n";
  $header .= "$encoded_content\r\n";
  $header .= "--$num--";
  # Send email now
  $retval = mail ( $to, $subject, "", $header );

  if( $retval == true )
   {
      echo "Message sent successfully...";
   }
   else
   {
      echo "Message could not be sent...";
   }
  
  
   
?>