Catalog Product update Magento 1.x – CSV

If you want to update attribute value for Magento catalog product in bulk, you can use CSV. Just create a CSV file with column SKU and respective attribute values for a product.

Using the above PHP script you can update multiple attribute value programmatically. You can set CRON to run this script automatically.

The above script capable to upload above 1 lakh products attributes value via CRON and CSV read from bottom to up that help when you have a very large file.

 

 

 

Magento Product XML Feed for Google Merchant Center

In this post, I will describe you how to add Magento products to Google Merchant Center.

What is Google Merchant Center?

Google Merchant Center is a tool that helps you upload your store and product data to Google and make it available for Shopping ads and other Google services.

Setting up the Google Merchant Center account

In order to use Google Merchant Center, you must first sign up for an account with Google. If you already have an account with Google (like Gmail), visit merchants.google.com and sign in to get started.

Just install extension from here: https://github.com/rahuldadhich/productxmlfeed

If you need more attributes or in case of any query/suggestion feel free to reach me on rahuldadhich87@gmail.com

Magento load CSS and JS in footer

By some online tools(tools.pingdom.com or Gtmetrix.com) It’s suggested that either load JavaScript(JS) files in footer of the page or deferred so that they don’t block downloading of other assets of the page like images etc.

By default Magento load JavaScript and CSS files in header section. Magento footer block is not designed to load JS and CSS in footer of page.

Here is solution for this problem:

Step 1: Add new layout in page.xml

Create a block same as page/html_head with name “footerjscss” to the page.xml

Step 2: Add JS/CSS using xml layout:

Now you can add JavaScript(JS) and CSS files in pages using any of your XML files

Step 3: Create view file:

Create .phtml file in page/html/footerjscss.phtml and add following

In your page template files “1column.phtml”, “2columns-left.phtml”, “2columns-right.phtml”, “3columns.phtml” and etc. you will need to output this block before <body> tag:

If you want to improve/increase Magento speed or optimize Magento performance read this: Magento Optimization

Thanks!!!

  • Rahul Dadhich.

WordPress WWW and non-WWW issue

How to redirect your WordPress site’s domain from non-www to www or vice versa. It is recommended that keep hostname of your website same throughout. Either use the www or without the www.

To redirect non-www to www

  1. Login to the dashboard of your WordPress website.
  2. Go to settings and then general.
  3. Locate the following fields:
    WordPress Address (URL): http://yourwebsite.com
    Site Address (URL): http://yourwebsite.com
  4. Replace both URL with adding www.
    WordPress Address (URL): http://yourwebsite.com
    Site Address (URL): http://yourwebsite.com
  5. Save setting.
    Now you will redirect to www version. you can see in url that www has been added.

Using .htaccess to redirect non-www to www

 

Creating Header and Footer Template in Codeigniter

When you are creating/developing large websites/applications you need to fragment your web-page in sections like navigation menu, header and footer. The navigation menu, header and footer usually stay same on all pages of your website/application. If you don’t use sections for your web-page and if you want to change something like logo in header, add link in navigation menu or add/edit description in footer then you have to change on all pages manually.

PHP already have solution for this problem with the include() method. With this method you can include any file within another file.

In Codeigniter, you can create custom method in Loader class and call group of views. Codeigniter have Loader Class, initialized automatically by the system, as the name of class, is used to load elements like libraries, helpers, models, view files or your own files.

Steps to follow:

  1. Create new php class extends CI_Loader in application/core directory

2. Create a method inside MY_Loader class named template

In this template method we have 3 parameters:

Now we call 3 views in this method, first for header, main template and then footer and return result if we want to show view as data otherwise this will show all called views in sequence.

Final code looks like:

 

Enable eCommerce Tracking for WooCommerce

Want to track your eCommerce sales data? To start tracking your sales data, first you’ll need to enable eCommerce tracking in Google Analytics account.

Follow below simple steps to enable eCommerce tracking in Google Analytics account:

  • First, you’ll need to log in to Google Analytics.
  • Then, select the website(property).
  • Next, click Admin in the menu bar
  • Now click eCommerce Settings.
Enable eCommerce tracking in google account
Enable eCommerce tracking in Google account
  • Next, click on Enable eCommerce, to turn it on. Then click the Next Step button.
Enable Ecommerce then click the Next Step button
Enable Ecommerce then click the Next Step button

Add Google Analytics eCommerce tracking code:

Open thankyou.php file from woocommerce/checkout directory.

Place below code at the end of file:

That’s it, just make test transaction and check in Google analytics after some time. Your sales data will be visible.

 

Thank you.

Keep code!

Protect WordPress with .htaccess | WordPress Optimization

WordPress is world’s most popular CMS, but with this growth, It also have some bad points. WordPress can be hacked easily, To get more security we can use some htaccess rules.

.htaccess is very common and most essential file. You can do lots of things by using .htaccess file.

Enable Browser Caching:

Browser caching allows users to speed up the loading time of websites by serve cached copy of design elements such as CSS stylesheets and media items such as images from users computer rather then website server.

To enabling browsing caching, you need to add this code to your .htaccess file:

GZIP Compression:

When visit webpage, request send to web server, if the server has gzip enable it receive gzip file which is significantly smaller and if it’s not enable it receive the page which is uncompressed version which may be bigger in size.

Gzip locates similar strings within a text file and replaces those strings temporarily to make the overall file size smaller. By gzip compressor reduce the size of page and style sheet by up to 70%

If your hosting provider has mod_gzip module enabled, the best way to compress your content is to add the following lines to your .htaccess file:

Enable gzip compression on Apache web-servers:

Enable compression on NGINX web-servers:

Keep Alive:

Display webpages in browser must request a file from web server, if file exists on web server browser gets the file and read the file. Then browser request other things like HTML, style sheets, JavaScript and images. If a new connection has to be open for every request or file it could take significantly longer time.

Keep alive also known as persistant connection that says “At a time you can get more more than just a single file”

Enable keep-alive in Apache:

Leverage browser caching:

Every time browser load web page it has to download all the web files like HTML, CSS, JavaScript, logo and images to properly display the page. Browser caching can help by storing some of these files locally in the user’s browser.

Browser caching is important is because it reduces the load on your web server, which ultimately reduces the load time of website.

Protecting wp-config.php:

Disable File Editing:

Protect WP-Includes:

If you are having problems implementing the above suggestion or beefing up the security, optimization of your WordPress installation, drop us an email. and we will gladly assist you.

PHP, MySQL, Ajax, Infinite Scroll with PhoneGap | Cordova

About PhoneGap:

Adobe PhoneGap is used to develop hybrid mobile applications. PhoneGap allows create app using web-development languages like HTML, CSS, and JQuery. You doesn’t require to have knowledge of mobile application languages like Java, Objective C, or Swift. PhoneGap extends the features of of HTML and JavaScript to work with the device.

Let’s start how to make simple infinite scroll application with MySQL database in phonegap.

Steps to follow:

  1. Create MySQL Database and Table
  2. Write PHP code on Server Side for handling request
  3. Write JQuery(Ajax) code on PhoneGap or Cordova side

Create MySQL Database and Table:

First, create MySQL database with table (user_details) with fields such as id, name, contact_number, address.

Connect to Database Server:

Display/Retrieve Data:

Get data from MySQL table with date filter and limit for enabling infinite scroll:

HTML code for PhoneGap / Apache Cordova Side:

Here we write simple HTML code with help of bootstrap classes.

First we showcase some filters elements then we listed data in list format:

Writing Jquery code for PhoneGap / Apache Cordova Side:

Using this code, on page load run Ajax to get data from MySQL table. For Infinite scroll when page scroll down same Ajax run again with incremented page number to get next set of data.

 

If you have any query or suggestion, So i’ll be happy to help you.

Thank you

.htaccees for Magento Performance Optimization

Magento is one of the most widely used eCommerce platforms today that people to choose to grown their online business. Optimizing the speed of your Magento allows customers to have the best user experience while shopping in your e-commerce store. In this post, you will get some tips to increase Magento speed and Magento performance optimization techniques.

Every e-commerce shop owner and users love the faster website. If website speed is slow user may leave a website and buy products from your competitors.
So you want to speed up your Magento store, here are some htaccess file tips:

Browser Caching & htaccess Configuration

Enable Output Compression
The apache mod_deflate module, which compresses text, CSS, and javascript before it is sent to the browser. This result lower file size.

Gzip Compression
This will compress stylesheet and web page before sending them to browser

Enable Expires Headers
To determine how long web page components cached in a browser cache. Web page static components like images, stylesheets.

Disable ETags
Entity tags (ETags) are a mechanism that web servers and browsers use to determine whether the component in the browser’s cache matches the one on the origin server. ETags were added to provide a mechanism for validating entities that are more flexible than the last-modified date.

Mime Type Caching

 

Magento load JavaScript(JS) and CSS files in footer: http://blog.rahuldadhich.com/magento-load-css-js-footer/

Thanks.

  • Rahul Dadhich

My First WordCamp Experience

I’d like to share my experience of WordCamp Udaipur which took placed on 28th Jan 2017. First of all, I would like to thank @Vajrasar to inform me about the WordCamp in first place. I have been a WordPress developer but never had the opportunity to attend a WordCamp. It was educational, inspiring, and I enjoyed the overall experience.

WordCamp Udaipur
WordCamp Udaipur

The venue was very good. Special thanks to  @Puneet and  #WCUdaipur organizers for awesome setup and management.

Following are some sessions which I liked the most.

  • Why we Indian Developers Fail… – Nirav Mehta
  • Hiring WP Devs – Rahul Bansal
  • Exploring the REST API V2 – Ayushdeep Singh
  • Templating with Underscore.js in WordPress – Achal Jain

Also Panel Discussion – Building a Successful WordPress Business was very helpful.

In #WCudaipur food was very delicious and also my thanks to sponsors for lots of #swag from WordCamp team and @resellerclub @buddyboss @ideabox @kitsune

 

Image courtesy: Anonymous
Image courtesy: Anonymous

My overall experience was very good. I’m glad that this WordCamp turned out to be a good experience, can’t wait for next WordCamp.

From this WordCamp, I learned that we need to step out from our comfort zone. When we come out of our comfort zone there are too many challenges in front of us, and we should face them, we may fail sometimes but if we don’t take those risks, you will never know the opportunities that you could be missing.

!!! IF YOU DON’T TAKE RISKS, YOU WILL ALWAYS WORK FOR SOMEONE WHO DOES !!!