Categories
Hosting Magento

Best Magento Hosting Company

When choosing the best Magento Hosting or Magento 2 hosting to host a small/medium sized Magento store, I always try to find out which company offers customers the most value. In my opinion, there are 4 things that make up a best Magento hosting.

  • Hosting performance, including Load speed, uptime, and capability to handle concurrent requests.
  • Magento specialized tool
  • Support: Knowledge, speed, and reliability of support on hosting problems and common Magento problem
  • Pricing: Price/value, Cheap and Affordable Magento with decent power.

SiteGround

Features 1-Click Install Magento
*Free Backup tool
Magento Optimized
24/24 support
Livechat + Ticket for common Magento issues
FREE SuperCaching + CDNFree Magento theme
Price – $3.95/month

Categories
PHP

PHP – Array Functions

Sort a numeric array having custom index values.
Suppose you are having a array like below.

<?php
	$array['ab']	=	'abc';
	$array['xy']	=	'xyz';
	$array['lm']	=	'lmn';
	
	$array['45']	=	'456';
	$array['78']	=	'789';
	$array['12']	=	'123';

//	Then you can use below solution to sort above array.

	echo '<pre>';print_r($array);
	//preserve arrays keys for later use
	$ar1	= array_keys($array);
	
	//preserve array's values for later use
	$ar2	= array_values($array);
	
	//perform sorting by value and then by key
	array_multisort($ar2, SORT_ASC, $ar1, SORT_ASC);
	
	//combine sorted values and keys arrays to new array
	$sorted_array = array_combine($ar1, $ar2);
	
	echo '<pre>';print_r($sorted_array);
?>

Output will be 
Array
(
    [12] => 123
    [45] => 456
    [78] => 789
    [ab] => abc
    [lm] => lmn
    [xy] => xyz
)
Categories
Magento

Magento Ebay Feeds

I have created a custom magento code (Magento Ebay Feeds) which can export magento products to csv and that csv can be easily imported to eBay.  My extension allows to import products, pricing, description, images and more data from your “Magento Store” to your eBay. The Extension can export simple and configurable products transforms them into eBay compatible csv format. Imported products start showing on your eBay store instantly. You need to simply import that csv to your eBay store.

This extension is similar to
Ebay2Magento – http://magegaga.com/ebay2magento.html
eBay Integration    –    https://www.magentocommerce.com/magento-connect/ebay-integration.html

Please let me know if you are looking for Amazon Integration for Magento like –    https://www.mag-manager.com/magento-amazon-integration/

Categories
PHP

Compiled vs. Interpreted Languages

What is compiler
A compiler is a computer program that transforms source code (programming language/source language) to another computer language (the target language). The most common reason for converting source code is to create an executable program.

The name “compiler” is used for programs that translate source code from a high-level programming language to a lower level language (e.g., assembly language or machine code).

Compiler v/s Interpreter

Compiled language v/s Interpreted language
A compiled language is one where you have to compile the code before it can be executed. The compilation process, for those that don’t know it, transforms the source code into object code; the later can be directly executed by the microprocessor (as it’s formed by opcodes), while the former can’t. So, more generically, a compiled language can be executed, after compilation, without any helper utility. Examples of these include C, C++ and assembler.

An interpreted language is one where you can execute the code without compilation, by means of an interpreter. An interpreter reads the code from the source file and executes it, without converting it to machine code (forget about JIT compilers for now). The way this is done depends on the specific interpreter you are using; but to get an idea, they often construct a parse tree – an in-memory representation of the code structure – from the source file and then evaluate it. Examples of these include Perl, Python, PHP, Basic and POSIX shell scripting.

Sources
https://www.quora.com/What-is-the-difference-between-compiled-and-interpreted-programming-languages

Difference between Compiler and Interpreter

Categories
Magento PHP Security

Magento : How to apply SUPEE-5344 and SUPEE-1533 from the Magento Community Edition

Urgent: Immediately install Magento critical security patches.

It is critical for you to download and install 2 previously-released security patches (SUPEE-5344 and SUPEE-1533) from the Magento Community Edition download page (https://www.magentocommerce.com/products/downloads/magento/).

1. Go to https://www.magentocommerce.com/products/downloads/magento/ and download the right version of patches.

2. Upload your files into Magento root directory. It is important to place patch files directly into Magento root directory and execute it also directly in Magento root directory.

3. Run the patches like this
# bash ./PATCH_SUPEE-1533_EE_1.12.x_v1-2015-02-10-08-19-16.sh
Checking if patch can be applied/reverted successfully…
Patch was applied/reverted successfully.

# bash ./PATCH_SUPEE-5345_CE_1.7.0.2_v1-2015-02-10-08-11-22.sh
Checking if patch can be applied/reverted successfully…
Patch was applied/reverted successfully.

4. Verify if the patch is added successfully
Test that your store is working fine. Login to admin and clear all the cache from cache management and flush other PHP opcode caches(APC/XCache/eAccelerator) if you are using, otherwise code will continue to run from caches.

Verify that your store have green SAFE status at https://shoplift.byte.nl

Please read below if you get errors while running the above bash command.

Note – While running the bash commands mentioned in step 3, if you get errors like below-:
Error! Some required system tools, that are utilized in this sh script, are not installed:
Tool(s) “patch” is(are) missed, please install it(them).
Then you need to first install patch like this

# yum install patch

4. Once you install the patch then follow the step 3.

Source

If you are using a shared hosting or don’t have ssh access to install the security patches then please follow this link – How to apply SUPEE-5344 and SUPEE-1533 without SSH

Categories
Magento PHP

Magento : How to Convert Price from Current Currency to Base Currency

If in some case you want to convert the price to base corrency in Magento then there is a very simple function available ‘currencyConvert()’ but this function is NOT WORKING in magento community 1.7 version.

<?php
$from 		= 'USD';
$to 		= 'NPR';
$price 		= 10;
$newPrice 	= Mage::helper('directory')->currencyConvert($price, $from, $to);
?>

Source

magento convert price in base currency
I tried another way to solve this. You can use the below working code to get the price in base currency.

<?php
//	Convert price to base currency from current currency
$totals 	= 	Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
$subtotal 	= 	$totals["subtotal"]->getValue();
// Base Currency
$baseCurrencyCode 		= 	Mage::app()->getStore()->getBaseCurrencyCode();
// Current Currency
$currentCurrencyCode 	= 	Mage::app()->getStore()->getCurrentCurrencyCode();
if( $baseCurrencyCode != $currentCurrencyCode ){
	// Allowed currencies
	$allowedCurrencies 	= 	Mage::getModel('directory/currency')->getConfigAllowCurrencies();
	$rates 				= 	Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
	$convertedSubtotal	=	$subtotal / $rates[$currentCurrencyCode];	
}else{
	$convertedSubtotal	=	$subtotal;
}
?>

Source

Categories
PHP

PHP : How to check Browser on Server Side using HTTP_USER_AGENT

While dealing with jQuery and JavaScript i sometime need to check the browser version and then code accordingly. The following simple php code will let you know the correct browser version 🙂

<?php	//	Added by Vaseem to check the IE Browser Version on Server Side using HTTP_USER_AGENT
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE){
	echo 'Internet explorer';
	if (stristr($_SERVER['HTTP_USER_AGENT'], "msie 10")){	//	Use msie 8, msie 9 to check if browser is IE8 or IE9
		echo 'IE 10';
	}
}elseif (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) {
	echo 'IE 11';
}elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE){
	echo 'Mozilla Firefox';
}elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE){
	echo 'Google Chrome'; 
}elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== FALSE){
	echo "Opera Mini"; 
}elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== FALSE){
	echo "Opera"; 
}elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== FALSE){
	echo "Safari"; 
}else{
	echo 'Something else';
}
?>
Categories
Magento

Magento : How to get Product Reviews posted during a time period

Customer reviews for your products and services always play a vital role in the success of your business. As magento have inbuilt functionality of reviews for products and when a customer write a review for product then the approved reviews will show on the product pages. If you are using service of Google Merchant Review Feeds then you need to submit the reviews posted between a specific dates. The following code snippet will be useful for you to get the magento product reviews.

How Magento Reviews are useful for growth of your business

<?php		// Added by Vaseem to get the product reviews posted during a time period
$fromDate	=	'2014-04-01 00:00:00';
$toDate		=	'2014-04-01 23:59:59';
$_reviews 	= 	Mage::getModel('review/review')
                ->getCollection()
                ->addStoreFilter(Mage::app()->getStore()->getId())
                ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
                ->addFieldToFilter('created_at', array('from'=>$fromDate, 'to'=>$toDate))
                ->setDateOrder()
                ->load();
foreach($_reviews as $review){
    $product 			= 	Mage::getModel('catalog/product')->load($review->getData('entity_pk_value'));
    $review_id			=	$review->getData('review_id');
    $created_at			=	$review->getData('created_at');
    $entity_id			=	$review->getData('entity_id');
    $entity_pk_value	=	$review->getData('entity_pk_value');
    $status_id			=	$review->getData('status_id');
    $detail_id			=	$review->getData('detail_id');
    $title				=	$review->getData('title');
    $detail				=	$review->getData('detail');
    $nickname			=	$review->getData('nickname');
    $customer_id		=	$review->getData('customer_id');
}
?>

I hope the above code will be useful for you 🙂

Categories
Wordpress

Disable Update Notification for Individual WordPress Plugins

Well i strongly recommend to update the WordPress plugin whenever a new update is available. This is required for proper functioning of your WordPress website and also prevents hacking of your WordPress website. Plugin developers are constantly fixing bugs, closing security gaps, increasing efficiency, and updating other aspects of the plugin that will benefit your site.

But there might be a situation where you would want to hide a plugin update notification. Suppose if are working for some non technical client or if you have made some modifications to a plugin that you don’t want to be overwritten?

Here are 2 simple tricks to hide the plugin update notification.

Trick 1 – Modify Plugin Version
The easiest solution is to open up the PHP file in the plugin root directory and modify the version number. At the top of the file, there will be some commented out variables that WordPress pulls in. You can update the plugin version from 1.1 to 100.1. A version number so high that the plugin will never get there, for example 100.1.

Plugin Name: WordPress PopUp
Plugin URI: http://premium.wpmudev.org/project/the-pop-over-plugin/
Description: Please don’t upgrade this plugin. If required then please contact Vaseem Ansari to upgrade it. Allows you to display a fancy PopUp to visitors site wide or per blog. A *very* effective way of advertising a mailing list, special offer or running a plain old ad.
Version: 1.1.2
Author: WPMU DEV
Author URI: http://premium.wpmudev.org
Textdomain: popover
WDP ID: 123

Trick 2 – Prevent Update Notification by Modifying Theme functions.php file
Another solution is to open the functions.php file of your WordPress theme and add the below function there. This function will disable the individual plugin update notifications in WordPress admin. By using this trick you can disable update notifications for specific/individual plugin.

/**
* Hide the notice of plugin update available in admin There is a new version of WordPress PopUp available. View version 1.1.3 details or update now.
* Usage – Automatic
*/
function hide_akismet_plugin_updates( $value ) {
unset( $value->response[‘akismet/akismet.php’] ); // For example if you don’t want WordPress to show update notifications for akismet plugin.
return $value;
}
add_filter( ‘site_transient_update_plugins’, ‘hide_akismet_plugin_updates’ );

function hide_wordpress_popup_plugin_updates( $value ) {
unset( $value->response[‘wordpress-popup/popover.php’] ); // For example if you don’t want WordPress to show update notifications for wordpress-popup plugin.
return $value;
}
add_filter( ‘site_transient_update_plugins’, ‘hide_wordpress_popup_plugin_updates’ );

Some Useful Reference
Disable update notification for individual plugins
Disable All WordPress Updates
7 Ways to Disable Update Notifications and Maintenance Nags in WordPress

Categories
jQuery PHP Wordpress

WordPress : How to Add Infinite Scroll to Home & Category Pages

I was working on Infinite Scroll functionality in WordPress. Initially i was trying to use jetpack (WordPress plugin) to implement the same but i was not able to understand how jetpack works and i did not get proper screenshot and online support to make me understand it properly. So i have Goggled more and finally i successfully implemented Infinite Scroll on VaseemAnsari.com. You can check the home page, category page, archive page and other pages where pagination generally comes.

Let me guide you how easy it is and how can you implement the same Infinite Scroll on your WordPress blog.
Step 1. This simple functionality uses javascript “jquery.infinitescroll.min.js”. You can download a copy of “jquery.infinitescroll.min.js” from the GitHub repository, and drop it into the “scripts” or “js” folder of your WordPress theme.

Step 2. Use any Ajax loader image. I hope you already have so many or you can find loading images on Google. You can pick out the ajax-loader.gif of your choice, and add it to your theme “images” folder.

Step 3. You need to register and enqueue the required jquery.infinitescroll.min.js script in functions.php (You can find this file in your wordpress theme.)

function custom_theme_js(){
	wp_register_script( 'infinite_scroll',  get_template_directory_uri() . '/js/jquery.infinitescroll.min.js', array('jquery'),null,true );
	if( ! is_singular() ) {
		wp_enqueue_script('infinite_scroll');
	}
}
add_action('wp_enqueue_scripts', 'custom_theme_js');

Step 4. Then you need yo use below function to make the magic happen. You can write this function in functions.php file.

function custom_infinite_scroll_js() {
	if( ! is_singular() ) { ?>
	<script>
	var infinite_scroll = {
		loading: {
			img: "<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif",
			msgText: "<?php _e( 'Loading the next set of posts...', 'custom' ); ?>",
			finishedMsg: "<?php _e( 'All posts loaded.', 'custom' ); ?>"
		},
		<?php /*?>
			img				: 	The path to the ajax loader image, we put the image in plugin folder
			nextSelector	: 	Selector for the “previous posts” link.
			navSelector		: 	Containing selector for the previous/next navigation links.
			itemSelector	: 	Selector for posts. This might be .hentry, .post, .etc
			contentSelector	: 	Containing div for your posts
		<?php */?>
		"nextSelector":"#nav-below .nav-previous a",
		"navSelector":"#nav-below",
		"itemSelector":"article",
		"contentSelector":"#content"
	};
	jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );
	</script>
	<?php
	}
}
add_action( 'wp_footer', 'custom_infinite_scroll_js',100 );

Check out below screenshot to know how Infinite Scroll works on my blog Twenty Thirteen and Twenty Twelve theme.

Simple Steps to add Infinite Scroll to a WordPress Blog
I have added Infinite Scroll functionality on my WordPress website. Check out the home page to see how it works

I have added Infinite Scroll to WordPress Twenty Thirteen and Twenty Twelve theme. If you have any issue in finding the proper div selectors of your theme then check below images. These images will help you to find selectors in Twenty Thirteen and Twenty Twelve Theme

You can see the Infinite Scroll working at below urls.
Twenty Thirteen Theme
Twenty Twelve Theme

I hope the above work out for you and if you still feel any issues then check the original link that helped me a lot.
Source