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.

 

 

 

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: