.

.

Unknown collation: 'utf8mb4_unicode_ci' Cpanel

I have a wordpress database on my local machine that I want to transfer to a hosted phpMyAdmin on Cpanel. However when I try to import the database into the environment, I keep getting this error.

#1273 - Unknown collation: 'utf8mb4_unicode_ci' 

Solution : This can be solved by running a PHP script. Save this code to a file and run it entering the database name, user and password and it'll change the collation from utf8mb4/utf8mb4_unicode_ci to utf8/utf8_general_ci
<!DOCTYPE html>
<html>
<head>
  <title>DB-Convert</title>
  <style>
    body { font-family:"Courier New", Courier, monospace;" }
  </style>
</head>
<body>
<h1>Convert your Database to utf8_general_ci!</h1>
<form action="db-convert.php" method="post">
  dbname: <input type="text" name="dbname"><br>
  dbuser: <input type="text" name="dbuser"><br>
  dbpass: <input type="text" name="dbpassword"><br>
  <input type="submit">
</form>
</body>
</html>
<?php
if ($_POST) {
  $dbname = $_POST['dbname'];
  $dbuser = $_POST['dbuser'];
  $dbpassword = $_POST['dbpassword'];
  $con = mysql_connect('localhost',$dbuser,$dbpassword);
  if(!$con) { echo "Cannot connect to the database ";die();}
  mysql_select_db($dbname);
  $result=mysql_query('show tables');
  while($tables = mysql_fetch_array($result)) {
          foreach ($tables as $key => $value) {
           mysql_query("ALTER TABLE $value CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
     }}
  echo "<script>alert('The collation of your database has been successfully changed!');</script>";
}

?>


Rewrite URL after redirecting 404 / 500 error htaccess


.htaccess is a configuration file for use on web servers running the Apache Web 
Server software. When a .htaccess file is placed in a directory which is in turn 
'loaded via the Apache Web Server', then the .htaccess file is detected and executed
 by the Apache Web Server software. 
These .htaccess files can be used to alter the configuration of the Apache Web Server
 software to enable/disable additional functionality and features that the Apache
 Web Server software has to offer. These facilities include basic redirect 
functionality, for instance if a 404 file not found error occurs, or for more
advanced functions such as content password protection or image hot link prevention.
 
 
ErrorDocument 404 http://example.com/404/
ErrorDocument 500 http://example.com/500/
# or map them to one error document:
# ErrorDocument 404 /pages/errors/error_redirect.php
# ErrorDocument 500 /pages/errors/error_redirect.php

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /pages/errors/404.php [L]

RewriteCond %{REQUEST_URI} ^/500/$
RewriteRule ^(.*)$ /pages/errors/500.php [L]

# or map them to one error document:
#RewriteCond %{REQUEST_URI} ^/404/$ [OR]
#RewriteCond %{REQUEST_URI} ^/500/$
#RewriteRule ^(.*)$ /pages/errors/error_redirect.php [L]

 

Display Currency Code Or Symbol in invoice pdf without changing core files

1.Download font that support Any Symbol Like  Indian Rupee symbol. recommended dejavu-sans font.
http://dejavu-fonts.org/wiki/Download
https://sourceforge.net/projects/dejavu/files/dejavu/2.36/dejavu-sans-ttf-2.36.zip/download

2.Place the font in lib directory(projectname/lib).

3.open app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php and app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php

copy paste both files under local
a) app/code/local/Mage/Sales/Model/Order/Pdf/Abstract.php b) app/code/loacl/Mage/Sales/Model/Order/Pdf/Items/Abstract.php

and replace

$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_Re-4.4.1.ttf');

with

$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/dejavu-sans/DejaVuSans.ttf');

(in _setFontRegular(), _setFontBold(), _setFontItalic() functions in both files.)

Admin -> System --> Manage Currency -->Symbols --> Copy your symbol and save.

Magento Code Pool

Magento has three code pools:
community
core
local
Core: It contains all Magento default modules
Community and local: We use these code pools for our custom module development.

app/code/core - Holds modules that are distributed with the base Magento and make up the core functionality.
app/code/community - Holds modules that are developed by third-parties
app/code/local - Holds custom modules you developed, including Mage code overrides.
Magento use two code pool for our customization
Magento actually uses three code pools. It will load local first, community second, and core third. It uses three for organization purposes and to help solve issues when two+ 3rd party extensions are trying to rewrite the same thing.
Magento don't use single code pool for customization.
It was done this was to try to have some code organization. Also, when you have 3rd party conflicts, the local is great to help solve those issues. The local is also great to have extensions that only that site will ever have.

Get Logged In UserInfo from outside Magento Programmattically



Create a file in root directory. Include mage File under app.
Create file Like getuserinfo_webservice.php in root directory.
<?php
require_once 'app/Mage.php';
    Mage::app('default');    
    Mage::getSingleton("core/session", array("name" => "frontend"));
 
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
 
    // Load the customer's data
    $customer = Mage::getSingleton('customer/session')->getCustomer();
 if($customer->getId())
 {
 $customerId = $customer->getId();
 }
 else
 {
  $customerId='';
  
  }
 
 
  if( $customer->getName())
  {
     $fullname= $customer->getName(); // Full Name
  }
  else
  {
   $fullname='';
   }
  
 if($customer->getFirstname())
 { 
    $firstname==$customer->getFirstname(); // First Name
 }
 else
 {
 $firstname="";
 }
 
 if($customer->getMiddlename())
 {
    $middlename=$customer->getMiddlename(); // Middle Name
 }
 else
 {
 $middlename=""; 
 }
 
 if($customer->getLastname())
 {
    $lastname = $customer->getLastname(); // Last Name
 }
 else
 {
  $lastname='';
    }
    
 
   if($customer->getEmail())
   {    
    $emailId = $customer->getEmail();
   }
   else
   {
   $emailId=''; 
   }
    
    if($customer->getGender())
 {
    $gender=$customer->getGender(); // ID
 }
 else
 {
  $gender='';
  }
 if($customer->getDefaultBilling())
 {
    $defaultbillingId=$customer->getDefaultBilling(); // ID
 }
 else
 {
 $defaultbillingId=''; 
  }
  
  if($customer->getDefaultBilling())
 {
    $defaultshippingId=$customer->getDefaultShipping(); // ID
 }
 else
 {
 $defaultshippingId=''; 
  }
    
    $customer->getDob(); // yyyy-mm-dd hh:mm:ss
 if($customer->getDob())
 {
    $dob=$customer->getDob(); // ID
 }
 else
 {
 $dob=''; 
  }
 
    $customer->getTaxClassId(); // ID
 $data['responseCode']='1';
 $data['msg']="Successfull";
 $data['result']=array("customerId"=>$customerId,"fullName"=>$fullname,"firstName"=>$firstname,"middleName"=>$middlename,"lastName"=>$lastname,"defaultBillingId"=>$defaultbillingId,"defaultShippingId"=>$defaultshippingId,"dob"=>$dob,"emailID"=>$emailId,"gender"=>$gender);
 
}
else
{
 $data['responseCode']='0';
 $data['msg']='Please Login First';
 }

echo json_encode($data);
?>