Blog Directory

How to do External Database Connection in Magento

How to do External Database Connection in Magento

Mostly, a single database connection is required only while working with Magento. Magento has excellent features to add new tables to the database or extend the existing ones. So why do we need an external database connection outside the Magento? Well, data migration from other e-commerce systems is one of the examples.

In this blog here, I am going to tell you a simple way as how to do external database connection in Magento with CRUD (create, read, update, delete) examples.

Configuration

In XML configuration, the external database connection is similarly defined as the Magento default one. The difference between internal and foreign connection is that foreign connection is defined inside the particulars module’s XML configuration. It defines read and write adapters and sets up the database credentials. Foreign tables are also defined in the same way as Magento table. They are defined under abc_foreignconnection_resource node so the model resource can be called later in the code. For a demo, here is a frontend node in XML config.

<?xml version=”1.0″?>

<config>

<modules>

<Inchoo_ForeignConnection>

<version>1.4.2</version>

</Inchoo_ForeignConnection>

</modules>

<global>

<models>

<inchoo_foreignconnection>

<class>Inchoo_ForeignConnection_Model</class>

<resourceModel>inchoo_foreignconnection_resource</resourceModel>

</inchoo_foreignconnection>

<inchoo_foreignconnection_resource>

<class>Inchoo_ForeignConnection_Model_Resource</class>

<entities>

<product>

<table>product_description</table>

</product>

</entities>

</inchoo_foreignconnection_resource>

</models>

<resources>

<inchoo_foreignconnection_write>

<connection>

<use>inchoo_foreignconnection_database</use>

</connection>

</inchoo_foreignconnection_write>

<inchoo_foreignconnection_read>

<connection>

<use>inchoo_foreignconnection_database</use>

</connection>

</inchoo_foreignconnection_read>

<inchoo_foreignconnection_setup>

<connection>

<use>core_setup</use>

</connection>

</inchoo_foreignconnection_setup>

<inchoo_foreignconnection_database>

<connection>

<host><![CDATA[localhost]]></host>

<username><![CDATA[username]]></username>

<password><![CDATA[password]]></password>

<dbname><![CDATA[db_name]]></dbname>

<initStatements><![CDATA[SET NAMES utf8]]></initStatements>

<model><![CDATA[mysql4]]></model>

<type><![CDATA[pdo_mysql]]></type>

<pdo_type><![CDATA[]]></pdo_type>

<active>1</active>

</connection>

</inchoo_foreignconnection_database>

</resources>

</global>

<frontend>

<routers>

<inchoo_foreignconnection>

<use>standard</use>

<args>

<module>Inchoo_ForeignConnection</module>

<frontName>fconn</frontName>

</args>

</inchoo_foreignconnection>

</routers>

</frontend>

</config>

Model

The next thing is the model which is used to define a foreign connection to get or save data in any foreign database. Here the model is initialized with the product table from XML configuration, which in this case defines product_description table.

class Inchoo_ForeignConnection_Model_Product extends Mage_Core_Model_Abstract

{

protected $_eventPrefix = ‘inchoo_foreignconnection_product’;

protected $_eventObject = ‘product’;

protected function _construct()

{

$this->_init(‘inchoo_foreignconnection/product’);

}

}

The model resource class is defined as the same xml config node in _init()function, but with the table_primary_key parameter. Several functions can be created in this class which can work with external data.

1st Example is CreateDataInResource function, which will insert data into model’s table. It takes an array of parameters which are required to be inserted.

2nd Example is ReadDataFromResource function which fetches all the data from the model’s table. Read adapter should be defined first. It’s a configuration node from XML which defines read connection. After the read adapter definition, other Magento database connection such as (select(), from(), limit(), etc) can be used. Read adapter will execute the query once it is constructed completely.

To fetch data, one can use these functions FetchPairs() or FetchAll(). FetchAll is used to get all the records returned from MySQL.

UpdateDataInResource and DeleteDataInResource functions requires additional $id parameter that defines which record is going to be updated or deleted.

class Inchoo_ForeignConnection_Model_Resource_Product extends Mage_Core_Model_Resource_Db_Abstract

{

const TABLE_PRIMARY_KEY = ‘product_id’;

protected function _construct()

{

$this->_init(‘inchoo_foreignconnection/product’, self::TABLE_PRIMARY_KEY);

}

public function createDataInResource($values = array())

{

$writeAdapter = $this->_getWriteAdapter();

try {

$writeAdapter->insert(

$this->getMainTable(),

$values

);

} catch (Exception $e) {

Mage::log(‘Unable to insert data to external resource. ‘ . $e->getMessage(), null, null, true);

}

}

public function readDataFromResource()

{

$data = array();

$readAdapter = $this->_getReadAdapter();

$select = $readAdapter->select()

->from($this->getMainTable(), ‘*’)

->limit(20);

try {

$data = $readAdapter->fetchAll($select);

} catch (Exception $e) {

Mage::log(‘Unable to fetch data from external resource. ‘ . $e->getMessage(), null, null, true);

}

 

return $data;

}

public function updateDataInResource($id, $values = array())

{

$writeAdapter = $this->_getWriteAdapter();

try {

$writeAdapter->update(

$this->getMainTable(),

$values,

self::TABLE_PRIMARY_KEY . ‘=’ . $id

);

} catch (Exception $e) {

Mage::log(‘Unable to update data in external resource. ‘ . $e->getMessage(), null, null, true);

}

}

public function deleteDataFromResource($id)

{

$writeAdapter = $this->_getWriteAdapter();

try {

$writeAdapter->delete(

$this->getMainTable(),

self::TABLE_PRIMARY_KEY . ‘=’ . $id

);

} catch (Exception $e) {

Mage::log(‘Unable to delete data from external resource. ‘ . $e->getMessage(), null, null, true);

}

}

}

class Inchoo_ForeignConnection_Model_Resource_Product_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract

{

public function _construct()

{

$this->_init(‘inchoo_foreignconnection/product’);

}

}

Usage in Controller

All these below functions describes in IndexController class, but as they are defined in Model’s resource class, they can also be called in any controller class.

class Inchoo_ForeignConnection_IndexController extends Mage_Core_Controller_Front_Action

{

publicfunction indexAction()

{

// Create

$foreignProductCreate = Mage::getModel(‘inchoo_foreignconnection/product’)->getResource();

$foreignProductCreate->createDataInResource(

array(

‘product_name’ => ‘Product name’,

‘product_description’ => ‘Product description’

)

);

// Read

$foreignProductRead = Mage::getModel(‘inchoo_foreignconnection/product’)->getResource();

$result = $foreignProductRead->readDataFromResource();

var_dump($result);

// Update

$foreignProductUpdate = Mage::getModel(‘inchoo_foreignconnection/product’)->getResource();

$foreignProductUpdate->updateDataInResource(

3394,

array(

‘product_name’ => ‘Product name updated’,

‘product_description’ => ‘Product description updated’

)

);

// Delete

$foreignProductDelete = Mage::getModel(‘inchoo_foreignconnection/product’)->getResource();

$foreignProductDelete->deleteDataFromResource(3394);

}

}

In most cases, Magento uses different types of external connection to retrieve or send data, but sometimes an external database connection is a good to go thing. Give it a try and do let us know in the comment section below as how it worked.

 

Saima Naz

Jun 8, 2017

Using Artificial Intelligence To Create Websites And Apps

Using Artificial Intelligence To Create Websites And Ap...

An implementation of websites through the use of Artificial Intelligence is up and running and has been put into use in Tel Aviv, Israel. AI is a division of computer science that has to do with intelligence displayed by machines and goes into deep science with it. The Science that has made progression in the past decade is perfection and complacency which remains to be used.

Relegating the technological and robotics world now comes down to make technology as it perfects through robotics. Throughout the age of computers and the developing fields, there has been faultlessness which has met the eyes of designers. Willing to use voice communication which came into being through Eliza software has been in existence for more than one and a half decades.

Another issue of recognizing through an optical means is never a part of artificial intelligence but sound recognition and understanding are there at hand. With the launching of Wix Artificial Design and Intelligence (ADI) has shown a breakthrough in technology. Looking to be a rare introduction in the field, there has been a complimentary improvement you will see with it.

Artificial intelligence is a common implication which you will want to condescend and see the use of it in self-driving cars, content delivery networks and understanding human speech. Use of different devices to sense how certain features need to get examined are the basic purpose of artificial intelligence in most ways. A combination of mathematics and philosophy has to do with the implication of computer science as a notable common feature.

Latest Trends In Website Development Through Technology

This ADI provides a comprehensive improvement and recognition of data that 85 million users recognize with the technology. What you will find most explicit is that it gathers information online and makes efficient use you will need. Making best and more conservative implementation of content that needs to be placed on the website is through this technology named Wix.

A continuous implementation of this transfer of content is seen since the beginning to an end which has development done easily. It is the ADI that knows how to develop websites making compulsive integration and continuation of web development. As you might seem to use it, Wix provides cloud development to make HTML5 sites as well as mobile sites you require.

Almost 100 Million users are there who are continuously using the site for more marked development and improved web design. As there are premium and freemium models to get access to community forums, e-commerce, social plug-ins, e-mail marketing and contact forms. Seeing a variety that you might seem to connect with, has several advancements in working.

Easy Designing Through A More Advanced Way In Web Development

Achsaf is the Wix ADI and is the first web development tool that has been given the name and is implied with Artificial Intelligence applications. After every other season, Wix gets newer versions of the developer such as HTML5 that there in use. It is the improved version and gets its publicity as a new and more remarkable web developing tool which comes to good use.

The perfect use of options that has artificial intelligence implications is through content which gets read from beginning to completion. Once the website gets completed a conclusion with themes as well as other design features are then designed with requirements. A query is always there at hand and the consistent questioning leads it to have conclusive application to website development.

Asked a few questions it could lead you to make a home page of websites you are into designing for your personal or commercial use. When there is a combination of artificial intelligence and algorithms that make easy development through a design strategy put into action is through algorithms. Where there is a right intrusion a contention from a series of choices mark in billions making the select ones as a used choice in website development.

If there is no immediate response to the Wix ADI simulator there are still a variety of things you will want to look at making a more comprehensive selection of a design strategy. The simulator accesses information through the web and gets right data in the right location on the designed website you are making.

Saima Naz

Jun 7, 2017

Looming PHP 7 & Its Effect on WordPress

Looming PHP 7 & Its Effect on WordPress

It is no more a secret anymore that PHP 7 has gained a lot of popularity, more than its previous versions. There are some questions which arise while developing with this advance version of PHP such as how it will affect sites which run on WordPress.

PHP 7 is no doubt an advance update for server-side web development language, and not in PHP but it’s going to impact a lot on other PHP-powered CMS like Drupal, Joomla, and Magento.

Upgrades in Performances

The biggest performance upgrade in PHP 7 is the direct response to all the criticism for all the past performance issues for the platform. This new PHP 7 release will give a 50% increase for the apps and will be quicker than HHVM.

Double Speed

This latest new update is twice as fast as PHP 5.x. PHP 7 executes codes faster and requires only few servers to manage the same quantity of requests each second. For example, WordPress homepage now requires 72% fewer instructions to execute than previously.

Latest & Improved Operators

The two operators that make their debut on PHP 7 are Spaceship and Null Coalescing. The former makes the designers chained comparison briefer while the latter is supposed to check if something exists.

Function Type Clues

In PHP 7, you are now allowed to use Boolean, Integers, Floats and strings as function type hints. In addition to that, you can even declare a function’s return type. This will help in preventing you from passing and returning the wrong types from functions.

Engine Exception

Exceptions added in this latest release of PHP 7 engine will help designers to handle errors in applications. The new engine exception introduced in this version will replace these types of errors, which is a great news for designers. If they now witness any fatal error, they can immediately remove it.

Continuous 64-Bit Support

It is now possible to operate PHP on a 64-BIT Windows system with total confidence. This is no doubt a remarkable change because the earlier versions of PHP have failed to support 64-bit integers or bigger files.

Group Use Declaration

Group Use Declaration is another more interesting feature of PHP 7. They outstandingly have improved PHP namespace implementations. Now you can import as many classes as you want from the namespaces, all because of this syntax. Another benefit of this syntax is, you have to write less code.

Anonymous Class Support

Classes with no name help developers to enhance their coding and fasten the execution time. Well, other programming languages like Java and C# also let developers make use of anonymous classes in their code.

Abstract Syntax Tree

PHP 7 introduces Abstract Syntax Tree and for good reason. It is the middle phase in the whole language compilation process. AST (Abstract Syntax Tree) has come with lots of advantages like the possibility of more optimization, refined code quality and the chance to use tools such as static code analyzers.

Removal of Unacceptable Items

Good news, some deprecated features, unsupported or dead server APIs and extensions are removed in this latest version of PHP. Here see the list of removed items:

  • ASP style tags
  • PHP 4 style constructors.
  • Ereg and MYSQL extensions.

These are some necessary things to keep in mind while moving to PHP 7.

Notifications

Stay alerted for notifications. Hosting sites usually send the notification to the site owners prior to any PHP updates. Do tell your hosting provider if you missed anything by mistake.

WordPress Site Backup

It would be great if you save the copies of your WordPress site in multiple locations before migrating to PHP 7. This applies even when you think that the update will not break your site.

Update Before Migrate

Update all your site elements like the themes, plugins and the whole WordPress site before migrating to PHP 7. It is a wise precaution to ensure that all the site elements work fine even after the migration.

Talk to your Hosting Provider

Don’t feel shy in contacting your web hosts’ support team. Ask them if they are able to take care of all the site issues while migrating. Ask them to simply install a new copy of WordPress and then restore your whole site from the backup.

Wrapping it up

With all these updates, the release of PHP 7 sounds are all exciting for the developers and designers. The new update is designed with lots of features which has made the programming language faster and more improved.

Still scared in migrating to PHP 7? So it is recommended to follow all the precautions to avoid any mishaps.

Saima Naz

Jun 5, 2017

Education Web Design: 7 Elements that Influence Conversions

Education Web Design: 7 Elements that Influence Convers...

The road for conversion on any website is a long one. Countless of factors matters as why someone would take action on your site. In this post right here, we are going to talk about the most important user group on educational websites which intends to satisfy parents and students. Obviously, any educational website serves many purposes and both users are part of your organization but not necessarily both the users need to be served in the same way for conversions.

Let’s take a look at some key website elements which can help effect, achieve and encourage conversions.

1: Compelling and Attractive Headlines

There are lots of choices available for students when narrowing down their options for educational sites. In the process of researching, they will look at hundreds of websites recommended to them by others or seems appealing to them in some way. This is the reason that a compelling and straightforward headline is so much important.

If a user lands on your website, make them revisit your website again. This can be done through many things since it is difficult to focus on any single aspect of the website, so it’s better to make a bold, loud, stand-out and clear statement to convey your message rather than filling the page with a glut of information.

2: Quality Imagery

High-quality images go hands in hands with the compelling and appealing headlines. The homepage and landing pages of your educational website should feature quality photography which gives your user an immediate and positive reaction over that. Pairing with strong headlines or content and high-quality images will leave a long lasting impression on users, convincing them that they have landed in the right spot.

3: Clear, Defined User Paths

Education websites serve many user groups. And because of this reason, it is important to have clearly defined user paths to allow easy navigation according to the needs. Giving clear pathways to a relevant and specific content ensures you that the users don’t abandon your site just like that because they can’t find the information they are looking for.

4: Ease of Navigation

Educational websites are normally loaded with lots of information, which makes sense as it is fulfilling different needs of user groups and offers a huge number of different courses, programs which should be represented. However, displaying an enormous amount of content can be a challenge when it comes to representing it on the web. Web sites with a variety of content should focus on presenting in such ways which help in navigating the site towards the content which is relevant and useful.

5: The Right CTAs

Call-to-action buttons are incredibly an important factor in the conversion process. But it doesn’t force users to take that step instead it guides them the way which makes sense to them. The more satisfied and comfortable your users are, the more likely they will take a step to complete the conversion. Consider it necessary as how much information users require before they take any more serious and important steps such as giving their contact or card information. So ensure to include other options for users who are not yet ready to make any commitment.

6: Social Presence

Displaying Social proof on your website is one of a great way to gain user trust and get them connected with your educational institute on a more personal level. Word-of-mouth marketing, social shares, comments, mentions are now considered to be the digital equivalent of a conversation shared between people. Integrating social tools on your site shows that your educational institute possesses a thriving, engaging and successful community.

7: Mobile Optimized

Mobile optimized websites are a necessity now. Half of the users’ access web through their phones and Google takes mobile optimization as a ranking factor. The website without mobile optimization is a major drawback and a website performing poorly on the mobile screen is undoubtedly a conversion killer.

In a digital era, almost everyone expects websites to function on phones as fine as they do on desktop screens, so it’s wise to meet their expectations to generate leads and conversions.

In the End

We hope these 7 areas of focus discussed above will help you design your website in a way which influences conversions. Did we miss out any other factor? Do let us know in the comment below.

Saima Naz

May 31, 2017

Boosting Moodle Performance – Tips To Speed Up Your Moodle Website

Boosting Moodle Performance – Tips To Speed Up Your M...

Moodle, aka Modular Object-Oriented Dynamic Learning Environment, an open-source platform which lets you create interactive, collaborative content and online courses through Learning Management System (LMS) or Virtual Learning Environment (VLE).

Deploying any Moodle website can be very profitable. Moodle website owners can make the most out of their Modular architecture and can implement plenty of functional modules/extensions on the site to make the educational interface more attractive, interesting and engaging.

However, you might feel sometimes the decrease of your Moodle’s website load time and performance. With too many extensions installed on your Moodle site or being shrink on your Moodle hosting plan, can also give your Moodle website users a hard time. Since nothing can spoil the name and reputation of a website than its low speed and functionality.

I am going to share down here few tricks to optimize and speed up your Moodle website.

1: The Basic Tweaks

Before taking any further step towards optimization techniques, it is necessary for you to understand and consider first some of the basic things which can cause or make your Moodle website slow.

2: Get a Managed Moodle Cloud Hosting

Discover first whether the hosting plan you are on suits your website or not. If you are using shared hosting then obviously it’s the root cause for your Moodle website to function slowly and makes it more delicate for security threats as well.  Get Managed Moodle Cloud Hosting for better and adequate resources and security.

3: Baseline Monitoring

If using in-house servers then do monitor the components of the system which are the baseline of your Moodle site. For Linux Operating System, try LBS and for Windows Monitoring System, use performance monitor. Once you are done gathering the information about your system performance, you can now improve the performance and speed of your Moodle website by making changing in system components such as RAM, caching or Disk Space.

4: Operating System

Moodle runs on limited operating systems such as Windows, Linux, Mac OS and UNIX. But for the better performance, Linux is supposed to be the core Operating System on the servers which can run your Moodle website. Do check your hosting provider too and see if their systems are giving the recommended configuration to Moodle or not. If not, then change your hosting ASAP.

5: Additional Performance Tweaks for Desktops

If you are using FireFox, integrate firebug and then YSlow extension in it. This advance tool will tell you the exact loading time of each page of your Moodle website. Also, the YSlow tool will evaluate all the pages in contrast to Yahoo’s 14 rule for fast loading website and gives you the metrics of some common issues on your website. 

6: PHP Accelerators to less the CPU load

It is suggested for both in-house servers hosting providers to make use of PHP accelerators according to the PHP version. The PHP Accelerator will help to ease the load from the servers while processing PHP queries.

7: Check Memory Limit

The latest version of Moodle requires larger memory. Check the memory_limit in php.ini. If the Moodle version is earlier than ver1.7 then reduce the memory to 16M and for 1.7 versions, increase the memory limit to 40M.

8: Optimize the Performance of Apache Server

If your Windows server has Apache installed then use the Apache Lounge build version because this build of Apache is far better in performance and stability than the official one. Do remember one thing this version won’t keep you updated with the official patches and releases of Apache.

9: Increase MaxClients Memory Limit

Increasing the memory of MaxClients will leave 80% of the available memory for spare. Apache requires maximum 10 MB memory for processes increase up to 100MB. This whole thing will render your Moodle website pages fast.

Tip: Don’t increase the MaxClients value to above 256 as this would allow your server to eat more memory.

10: Tweak MYSQL Performance

Change MYSQL settings for better performance of the Moodle website. But make sure you have made the backup of the databases before taking any attempt to change the configuration of MYSQL.

Some Other Tools to Increase Moodle’s Performance

There are some other methods available to increase or boost up the load time for the Moodle website. Such as CDNs (Content Delivery Network) can make your Moodle website accessible for all and Memcached allows quick rendering of the web pages.

Well, these are some tips to speed up the performance of your Moodle Website. Hope they work for you. Got any other tip? Do let us know in the comment section below.

Saima Naz

May 29, 2017

Why are HTML Templates the First Choice of Designers?

Why are HTML Templates the First Choice of Designers?

This is no new trend. Html templates are the first choice of designers. Making use of Html templates was first started in the initial stages of web designing. No matter how advanced web technologies are, HTML will always lead the way. Some few reasons for the obvious fame for HTML are,

Compatibility with all Browsers

The HTML templates are supported by every browser such as Google Chrome, Firefox, and Internet Explorer, Safari etc. it is mainly because this markup language is very adjustable and recognizable by many browsers which let you display your website on screen regardless of any browser. Html templates are also accessible from any devices either desktop, laptops or mobile.

SEO Friendly

Hear, hear, Html templates are SEO friendly. It is easy for search engines to read websites of such templates as their coding is organized. All in all, this method helps to get rid of complex problems.

Get free quote from Professional Website Design and Development Agency.

Flexible Nature

Html is easy to understand by beginners and non-technical person. Because of its pliable nature, developers and designers can customize it accordingly.

These are some top reasons as of why the HTML templates are the first choice of designers and developers. Now let’s see some top best Html templates (free or paid) to create some brilliant portfolio websites, software or product app landing pages and much more.

The Fekra Multi Page HTML5 Template

Fekra, sounds strange. Doesn’t it? The template is a single page parallax suitable for an amazing range of industries and niches. It is mobile responsive and has an unlimited color palette to make the most of this platform. It’s so affordable with 50 demos and lets you create 270 unique pages. Well, this template is the best choice for advanced users.

Professional HTML5 Development Company.

the-fekra-multi-page-html5-template

Metronic – An HTML Dashboard Template

Metronic is the template enriched with varieties of functions and features. The theme consists of 7 admin templates, customer base of about 30,000 satisfied developers and also 1500 user interface features.

With a fully responsive capability, the template can be used for both professional and personal use. Do check it out and I am sure you’ll love the versatility of it.

metronic-responsive-admin-dashboard-html5-template

BeMobile – Mobile Responsive HTML Template

With the increasing number of mobile users, BeMobile html template took the advantage of this growing trend and made specifically for the mobile users. The template is fully customizable with 10 different homepage styles, bar styles and features which works only for mobile and commonly found in mobile phones only. The design feature of the template consists of touch device optimization, CSS3 design, ergonomic navigation and also tablet-specific responsiveness.

bemobile-top-html-theme

Smart Start- A Smart HTML Template

Smart Start is considered to be an ideal template for beginners but it’s not true. We have seen the template is so much versatile for experts too. If you are a graphic designer and wants to make the most of the layered PSD files or can’t live without Ajax infrastructures then you are definitely going to love Smart start. It is compatible with all browsers, mobile responsive and perfect for both HTML 5 and CSS3 users.

smartstart

Flex- A Flexible HTML Template

If you wants to showcase or display artworks, products or services then this template is best for you. The Flex template quickly, responsively and elegantly portrays the message without boring the audience with too much content. The template has built-in SEO functionality and allows the implementation of metadata, tags and etc.

flex

This is not the end

These are not the only best HTML templates but they are among them. Hence, it is now certain that HTML templates have their own identity in web designing and developing industry. Doesn’t matter how advance the web industry becomes, the value of this markup language can never be less.

Saima Naz

May 26, 2017

How to Avoid Sending Spam Emails in Magento

How to Avoid Sending Spam Emails in Magento

Every website owners are very much concerned about the emails being received by their users in their spam folders. People on different community forums are this major problem of emails being marked as spam so I thought to write up on this and shed some light on this topic for correct configuration and to create a checklist.

Obviously, this is no website owner goals to drop their emails into the spam folder. Emails are supposed to be sent to the inbox rather than in the spam. So, today I am going to tell you how to avoid sending spam emails in Magento.

How the Spam Filter Works

First, let me describe you shortly as for how the spam filter works, not just for Magento emails but for every mail. Whenever any email received to your server, and the spam filter is enabled, it will check all the incoming messages for a list of parameters.

Get Free Quote from Professional Magento Development Agency.

The parameter can either affect final spam rating in the positive or negative way. Marking whether the email is a spam or not is based on final scores. Average and recommended score to mark any mail as spam is 6.6. If the score is low then it won’t be marked as spam but if the scores are higher then it will go to the spam folder. In this blog, we are going to discuss some most common reasons for the rise of spam score and will provide you some tips to reduce it. Keep in mind, the lower the score is, the more likely the email is going to be sent to the user’s inbox.

The Steps to Avoid Spam Mails in Magento

  •         Server & IP Configuration
  •         Email Structure
  •         Email Content
  •         Testing Email Messages

To decrease the possibility of the spam emails, be ensure the server is configured correctly and the DNS contains all the necessary records. The email message should contain required headers and MIME parts.

Server & IP Configuration for emails in Magento

  • SPF DNS Record

Configure the domain SPF record correctly. SPF record is basically a TXT record in the DNS which has a list of all the IPs and hostnames, authorized specifically to send emails from the domain.

HOW IT WORKS: When any receipt server gets any mail, it checks the IP address for the authorized address.

  • Domain Keys

The mail server attaches a signature to every outgoing mail. The signature is used to verify sender server by reading public key located in the DNS record of the system. There are basically three parts: a private server, not visible to anyone on the server, used to generate email signature. A public key, listed in the DNS TXT record, used to verify that the email was signed with a private key of a specific server. But this point doesn’t stop spammers from sending emails using Google servers or others. This is just an additional layer of security.

  • Reverse DNS

Whether sending email from a server inside the domain, ensures that it has its own IP address and the hostname is resolved to that IP address.MX Record

MX Record is necessary for your domain. It basically tells which email servers is responsible for handling all the incoming emails for the domain. It is required if in case the email couldn’t get delivered to the receipt address, so the receipt server can send an undelivered notification.

  • White IP Address

Sometimes IP address can become blacklisted. After getting a new IP address from the provider, it is suggested not to use it for at least a month. The reason behind it is the new IP address might also be used by someone else. This time delay will clear the IP address and becomes “white”.

  • SMTP

One of the good solution to use SMTP server to send emails in Magento. It can either be public or private mail sector. Some paid SMTP services are also available on the web. Magento does not work with SMTP, so one need an extension for it. But here is one drawback, there are only a few extensions available in the market which send emails using their own method and will not work through SMTP. Also, maintain the server to ensure it works correctly and is backed up often.

The first part is completed, the server is now configured and is all ready to send emails out. Let’s move towards the second step and look at the email messages structure.

Recommended E-Mail Structure in Magento

  • Plain Text Part

The biggest problem in Magento is it doesn’t send the text part. It only sends HTML message part, giving such messages a higher spam score. The text can either be entered manually or can be created automatically.

  • Embedded Images

One can’t imagine an email without images. It is better to embed images directly into the message instead of linking them from remote resources.

Email Content Recommendation for Magento

  • Valuable Text

The text is important and useful for the readers. Bring value to it. Don’t do marketing for profit only. Don’t ever forget that your emails are read by humans.

  • No Image Emails – Do Html Coding

Avoid sending emails consisting a single image. It is no doubt hard to code email markup sometimes.Because single image emails are always considered as spam.

  • No Link Shorteners

Link shorteners can help you in building nice URLS because it is considered untrusted.  Your email will get up to 2 whole points for spam if any shortened link is found inside the email.

Testing Emails Messages in Magento

  • 3rd Party Service

Checking email in all apps is not possible to do manually. To get it done, you can use third-party services like litmus. It will generate previews of the messages on different platforms, web and desktop email clients. It is a very useful tool.

  • Use your Team

Once you are done with automatic testing, we would recommend you to send few copies to your circle, to get real life experience and feedbacks from live people.

  • Test Mobile View

Don’t ever forget to test the mobile view for Magento emails. Mobile marketing is continuously growing so the emails should look perfect on mobile devices too.

The End!!!

I hope this information comes handy to you. Got any more questions? Do comment below and I’ll be happy to help.

Saima Naz

May 24, 2017

4 Best Online Places to Learn Code for Free

4 Best Online Places to Learn Code for Free

A few years back, there was a time when programming was considered as the geekiest thing ever. But that’s not exactly the case for today. Nowadays everyone holds a certain level of potential, the chance to learn and even can master programming languages easily.

So, if you are new to the world of programming, coding and web development, then it does make sense to start teaching yourself by utilizing all the free resources available online. Forget about all the complicated setups and cold command prompts and say hello to these 4 online places for instant and interactive lessons to teach you the programming languages, website and app development, tips and even best practices of the industry top professionals.

To make learning easier, I have gathered here top 4 resources for you to learn the code free online. Let’s kick-start the path into programming and coding today.

CodeAcademy

Codeacademy is no doubt a famous learning source to teach you to code interactively. All thanks to codeacademy’s helpful interface and well-structured courses. Opening the main page, you can already start seeing and tasting the programming right away with its attractive on-screen console. Pick any of the courses that Codeacademy offers which includes Web development, PHP, Javascript, JQuery, Python, Ruby and APIs.

codeacademyhome

In every lesson that codeacademy gives contains a panel that explains necessary code and interaction. Another advantage of the panel is that it allows you to write acceptable code and then it checks if you are doing right or not. Not to worry about the mistakes you make while coding as both the instructions and code panel will warn you about the errors and will give you hint to solve. Learning with codeacademy will make you feel like as if there’s a teacher sitting right beside you.

Khan Academy

Khan Academy, although not structured like other resources, but it does offer an open playground for everyone, particularly who are interested in learning drawing, animation and user-interaction with code. It doesn’t offer any specific programming language to learn, but the coding technique can be applied anywhere since all the languages share the same programming pattern.

khanacademy

First, join the basic programming courses to learn and understand the basic concepts and then discover the code to after the video tutorial to clear the doubts.  With the Khan Academy tutorial, save your modification as a spin-off to enjoy and customize. There are hundreds of spin-off from one lesson in one course, so you can imagine well the community size of Khan Academy .

SQLZOO

SQL is the language designed to save and retrieve the data from the databases. Learning with SQLZOO will kill the boredom for you to learn SQL happily with its interactive interface and smileys.

sqlzoo

There is nothing really deep or impossible to learn or explain this straightforward language, the site will make you learn how to replace the variables and some more advanced queries. One biggest drawback about this tutorial is the shortage of hints, answers, and forum, so you can probably get lost if you are failing to answer any of the quizzes.

Code School

Once you are done with your basic learning and wants to expand your skills and capabilities, Code School is the best place to learn from. Unlike other interactive sites, Code Schools give you an in-depth learning and training to make you an expert with the help of industry’s best practices.

codeschool

The courses offered in CodeSchool are categorized in 4 main parts which are:

  •         Ruby
  •         JavScript
  •         iOS
  •         Html/CSS

Most of the courses offered are free and few of them are about $25/month for the entire course.

Good Luck

Missed any or know any other resources better than those above one, then do let us know in the comment below. Also share your experience about these resources as well.

Saima Naz

May 20, 2017

5 PHP Security Measures to Implement

5 PHP Security Measures to Implement

PHP is the most popular programming language and is being widely used for rapid development of dynamic websites. Web servers are publically accessible, so they possess possible security vulnerabilities.

PHP is a stable and almost an inexpensive web application platform. Like other web-based platforms, PHP is unsafe from external attacks too. For this, developers, database architects, and system administrators should take measurable precautions before deploying any PHP applications to a live server. These security techniques can get done with a few lines of code or some little adjustment to your application settings.

In this blog here, I have described in detail some of the most common vulnerability found in PHP web applications along with suggestions as for how they can be managed and prevented.

SQL Injection

SQL injection is the most common hacking type and specifically targets the database-driven websites or web applications which link or interacts with databases. The SQL injection is a type of code injection, where attackers make full use of the vulnerabilities in the website security measures to send special SQL queries to the database which can modify it and tables within it or delete the whole database.

Get free quote from professional PHP Development Company about your project.

This type of attack occurs when the developers fail to check data validation functionality in those areas of the website where the data from external sources can be inserted into the website. The attacker can easily add their own SQL statements in unprotected SQL queries which utilize data submitted by the user to check for something in the database.

For example:

An unprotected statement would be something like this

1 $query = “SELECT * FROM users WHERE username = ‘niki’”;

An SQL injection query will result in the following attempt:

1 $query = “SELECT * FROM users WHERE username = ” or ’1=1′”;

The result generated here will be true, and thus the content of entire table users would be displayed.

[related_posts]

In the SQL injection, attackers gains access to all the information in the database such as passwords, usernames, emails, and some other sensitive information.

How to prevent it?

  • The data should be validated, verified and cleaned up before entering it into the application
  • All the confidential information like passwords must be encrypted using SHA1 or SHA;
  • Technical information has technical details which can disclose security vulnerabilities to an attacker; so for safety purpose, it should be removed from error messages;
  • An attacker looks for error messages to hack information like database names, usernames and table names, therefore,  disable error messages or create your own custom error messages;
  • Limits the permissions granted on the database, since, fewer permissions will  result in fewer chances of hacking attack;
  • Use stored procedures and previously defined cursors to abstract data access so the users cannot directly access tables or views;
  •  Avoid using words such as ‘insert’, ‘update’, ‘drop’, and ‘union’ from being added to the database, as these all being words can alter tables and databases.

Remote File Inclusion and Remote Code Execution

The violation of this security measure will allow malicious or even unknown third party to run any code on the web server or on the client side and can even lead to other hacking attempts.

Remote file inclusion caused by a website susceptibility which lets the hackers to deploy malicious file on the web server. This can happen because of improper use of require() and include() functions if the register_globals directive, is ON, allowing the user to initialize variables remotely.  These remote variables can be used to include malicious or unwanted files from remote locations, and if the allow_url_fopen is enabled in php.ini, then remote files can also be uploaded to the site’s server via FTP or HTTP from any remote location.

How to prevent it?

  • Turn OFF the register_globals directive. Luckily, in advanced versions of PHP, it is by default OFF. If you want the directive to be ON for some reason, make sure all variables are properly initialized.
  • There are some other PHP directives which can be used to avoid this security breach, which includes: allow_url_fopen (by default turned on) which controls whether to include  remote files and should be turned OFF and allow_url_include (by default turned off) which controls whether include_once(), include(), require() and require_once() commands are able to include remote files into the code.
  • Enabling safe_mode which tests user ID permissions before opening any file.
  • Always validate user input and be careful with the data retrieved from remote servers or locations. To stop it, first, ensures that all files included are locally hosted and don’t ever accept files just like that unless necessary.
  • Restrict user permissions to help you stay protected from this security threat.

Cross Side Scripting (XSS)

Cross Site Scripting is one of the most common forms of hacking  Hackers use a legitimate site’s vulnerability to forcefully makes the site to do certain things. In XSS, the hacker infects a web page with the malicious client-side script and whenever a user visits that page, the script gets downloaded into the attacker’s  browser and executed. The pattern of XSS attack is depicted in the diagram below:

2

How to prevent it?

  • To stay protected from XSS, use escape functions, specially escape characters which comprises of HTML and JavaScript syntax like ‘>’ and ‘<’ or convert these into HTML entities, (for example, < would become this < ).
  • Sites like forums, where users posts HTML links, an alternative syntax like bbcodes (this is so common on forums) and can be used in order to overcome the escaping of HTML characters.
  • The htmlspecialchars () function identifies any output you do not want as a HTML output and converts it into plain HTML entities, for example: ‘&’ becomes ‘&’ and ‘”‘ (double quote) becomes ‘”’;
  • Do always check and test the website before launching it.

Session & Cookie Hacking

The session and cookie hacking can’t violate the database or the web application itself, but it can affect user accounts. A session is an entity triggered when users establishes contact with any web server and consists of some period of interaction between users and web application which may be authenticated using security measures like a username and password. In all this session, the web application stores a cookie or file on the user’s’ browser, which contains information about the session such as users’ preferences, authentication data, unique codes or shopping cart information and more.

3

How to prevent it?

  • To prevent hackers from setting session ID’s prior to login, ID’s must change after sometime, therefore, the session_regenerate_id() function must be used every time the user logs in, assigning them a fresh ID
  • The risk can be minimized by revalidating a user who is going to perform important or sensitive tasks like resetting the passwords .
  • If the user password is stored in a session variable, it should be encrypted by using the sha1() function.
  • If the web application contains sensitive information like debit and credit card numbers, then using an SSL or any other secured connection to avoid session and cookie hacking

Directory / Path Traversal

Directory aka Path traversal is a method of destroying web applications by accessing the files from the document root directory which allows attackers to view restricted files and interact with the web server by executing commands. This hacking attacks happens from the browser and get done by entering URL into the address bar which helps to let  out of the root directory and into the main server directories. This attack can also be done through input portals on the front end of the web application.

How to prevent it?

  • Validate and clean all the user input and remove all the suspicious data and filter out metacharacters;
  • Don’t ever store sensitive configuration files inside the web root.
  • If a suspect request any file to made, build the full file-path and all the characters in the path should be normalized (e.g. change %20 to spaces);
  • Careful programming on the web-server should be done. Make use of security software, patches and vulnerability scanners.

Security is an important phase in all the process. In this blog, I have mentioned here the top five PHP security measures to follow. Still got questions or need more information? Do comment below.

Saima Naz

May 19, 2017