Skip to main content

Posts

How to point Magento multi websites to domains

Backend configurations Add secure and unsecure domain urls for websites Add default domain url default config Index.php changes You need edit index.php file as follows switch($_SERVER['HTTP_HOST']) {     case ' domain.co.uk ':     case 'www. domain.co.uk ':         $mageRunCode = 'base';         $mageRunType = 'website';     break;     case ' domain.eu ':     case 'www. domain.eu ':         $mageRunCode = 'euwebsite';         $mageRunType = 'website';     break; } Comment following lines if you have /* Run store or run website */ $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';   Point main domain by adding your hosting server dns in domain registrar                 It will take some time to resolve DNS settings. Use intodns.com to check dns of a domain.   Then you need to poin

How to retrieve data from another table while retrieving data from a table in loadFormData function in Joomla 2.5

I have to show data from two different tables. Therefore I had to change 'loadFormData' function to satisfy that. Current implementation was as follows. /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormData()  { // Check the session for previously entered form data. $data = JFactory::getApplication()->getUserState('com_speakee.edit.batchofcard.data', array()); if (empty($data))  { $data = $this->getItem();                         }                          return $data; } Then I changed it to get data from another table called 'Discount' by calling table of 'Discount' and got table properties by primary key.  /** * Method to get the data that should be injected in the form. * * @return mixed The data for the form. * @since 1.6 */ protected function loadFormDat

Convert date from one timezone to another timezone PHP

This example is from phone call history  //set default time zone date_default_timezone_set('America/New_York'); //Set call date and time $call_date = new DateTime(date("d-m-Y H:i:s", strtotime($call['calldate']." ".$call['calltime']))); //Create new time zone object $la_time = new DateTimeZone('Europe/London'); //Set time zone to date $call_date->setTimezone($la_time); //show new date and time echo $call_date->format('d-m-Y'); echo $call_date->format("H:i:s"); Chamath Gunasekara

Replace empty names with concatenated text in MySQL

There was a drop down which had a huge list of employees. But some of them hadn't name. It was empty. But not NULL in database.  Initial query was as follows.  SELECT emp_id, name from employees order by name asc But it shows empty options in select list first. Then I tried to replace name which was NULL using IFNULL function.  SELECT aemp_id, IFNULL(name, concat('Employee - ', emp_id)) as name from employees  where name="" order by name asc But it was failed due to empty values for name field. Then I checked for empty value for name field.              NULLIF(name, "") It will return NULL value if it is empty. Then I used  COALESCE function.It returns first NULL or NULL if there no-null values in the list. Complete query as follows. SELECT emp_id, COALESCE(NULLIF(name, ""), concat('Employee - ', emp_id)) as name from employees where name="" order by name asc enjoy. Chamath Gunasekara

How to add Google fonts to select in TinyMCE editor in Joomla backend

There was a requirement from one of our customers to select Google fonts which we were using in front end pages in Tiny mice editors in Joomla 2.5 back end. I couldn't find a plug-in which provides this functionality from the back end. There are few plug-ins which can be used to enable Google fonts or font.com fonts by selectors (like class or ids).   Then I went through the source code of tiny mice editor plug-in found a way add new fonts. It was a bad thing when we think about joomla updates. But with client perspective it was a good solution I think. You are welcome to discuss with regards pros and cons.  Add new fonts here Edit editor_template.js file in  media\editors\ tinymce\ jscripts\ tiny_mce\ themes\ advanced\ editor_template.js Search for 'theme_advanced_fonts' or 'Arial' or 'georgia'. There are few places of 'theme_advanced_fonts'. You need to find correct place.  theme_advanced_fonts:"Andale Mono=andale mono,times;Arial=aria

How to create tar by excluding directories in centos Linux

I had a problem to compress files in my webserver. Because my images and backup folders were too large. Then I thought to exclude those directories and create a tar file. I have used --exclude option which matches patterns. First I have used following command to exclude images and backup folder. tar -cvf "new_tar_cha_2013-11-26.tar.gz" .  --exclude "path/to/backup/backup/*" --exclude "images/*" > error_tar_cha.log It excluded backup folder correctly. But It excluded all the images folders inside my directory. Because it matches the pattern . My solution was, I renamed to root images folder to different name - "images-cha1" and excluded it. It fixed my problem. tar -cvf "new_tar_cha_2013-11-26.tar.gz" .  --exclude "path/to/backup/backup/*" --exclude "images-cha1/*" > error_tar_cha.log I think this will be helpful for others also. Thanks