Magento 1: Export catalog categories for a specific store view

In this post you will learn how you can export Magento 1.9 categories for a specific store view as CSV.

For example, you have Arabic store view with ID 7, and you want to export all arabic category names in a CSV file, below will be the code you want.

Create a file on your Magento root and paste the below code, change the $storeId to your desired ID and run the script.


require_once 'app/Mage.php';

$storeId = 7;
$categories = Mage::getModel('catalog/category')
	->addFieldToFilter('is_active', 1)

$handle = fopen("var/export/categories_arabic.csv", "w");
$header = array('ID', 'Name');
fputcsv($handle, $header);

foreach($categories as $category){

	$row  = array($category->getId(), $category->getName());
    fputcsv($handle, $row);


After running the above script, you will find the exported CSV file `categories_arabic.csv` in the directory `var/export/`

Magento 1: Export manufacturers CSV by specific store view

This post will guide you on how you can export the manufacturer list (Magento 1.9) to CSV file.
In this script, I am filtering the list by store view. Let’s suppose you have a store view for Arabic (Store ID=1) and you want to export the manufacturer (Attribute ID= 555) list in Arabic labels only.
The below script will be helpful for you.


require_once 'app/Mage.php';

$manufacturer_attribute_id = 555; // Change attribute id as per your store setup
$storeId = 7; // Punch the store id for which you want to export the data
$collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
	        ->setStoreFilter($storeId, false);

$handle = fopen("var/export/manufacturers.csv", "w");
$header = array('ID', 'Name');
fputcsv($handle, $header);

foreach($collection as $manufacturer){
	$row  = array($manufacturer->getOptionId(), $manufacturer->getValue());
    fputcsv($handle, $row);


Navigate to your `var/export` folder and find the `manufacturers.csv`.

Please post your questions and queries in the comments box below.

Search Magento products by product labels

Project Overview:

Task was to develop a Product Labels Magento extension. Where admin can create product labels by uploading an image, enter label title and attach them to any number of products available in store. The label should display on front-end along with product information.
Continue reading “Search Magento products by product labels”

Creating Magento order programmatically and charging saved credit card.

Creating order is the basic functionality of Magento but its the trickiest one at the same time for developers. Yes, its true because its not straight forward like instantiating model, assigning some values and saving it. Sometimes you may want to create auto orders using some cron script.
Continue reading “Creating Magento order programmatically and charging saved credit card.”

Magento 2.0 : Fatal error: Uncaught exception ‘Magento\Framework\Exception\LocalizedException’ with message ‘Can’t create directory

You may encounter below fatal error While installing Magento 2.0

Fatal error: Uncaught exception ‘Magento\Framework\Exception\LocalizedException’ with message ‘Can’t create directory /home/tahir/www/magento-2.0/var/generation/Magento/Framework/App/ResourceConnection/.’ in /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Generator.php:103 Stack trace: #0 /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass(‘Magento\Framewo…’) #1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load(‘Magento\Framewo…’) #2 [internal function]: spl_autoload_call(‘Magento\Framewo…’) #3 /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct(‘Magento\Framewo…’) #4 /home/tahir/www/magento-2.0/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor(‘Magento\Framewo…’) #5 /home/tahir/www/magento-2.0/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(7 in /home/tahir/www/magento-2.0/vendor/magento/framework/Code/Generator.php on line 103


Changing permissions of /var directory will solve the issue. Run below command from root of your Magento 2.0 directory.

sudo chmod 755 -R var


How to install Laravel on Ubuntu

1. Install curl if not already installed

sudo apt-get install curl

2. install composer if not already installed

curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

3. Now run blow command to install laravel

composer global require "laravel/installer=~1.1"

4. Add laravel to PATH to make it available everywhere

export PATH="~/.composer/vendor/bin:$PATH"

5. Create your Laravel app

Now that Laravel is added to path, now all sudoers can create laravel apps using below command

laravel new app-name

if you are not a sudoer, above command will show below error

laravel: command not found

You can create a link in /usr/local/bin to solve this problem

sudo ln -s /root/.composer/vendor/bin/laravel /usr/local/bin/laravel

Now non sudoers can create laravel apps like

sudo laravel new app-name

6.Install mod_rewrite if not already installed

sudo a2enmod rewrite
service apache2 restart

You can confirm if its enabled using below command

sudo apache2ctl -M

if you created your app inside web server root directory (/var/www/html/) then you can access it like


Creating VHOST for Laravel application

1. Create vhost file

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/
sudo nano /etc/apache2/sites-available/

The file will look something like this (I’ve removed the comments here to make the file more approachable):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

First, we need to change the ServerAdmin directive to an email that the site administrator can receive emails through.


Then ServerName and ServerAlias


The only other thing we need to change for a basic virtual host file is the location of the document root for this domain. We already created the directory we need, so we just need to alter the DocumentRoot directive to reflect the directory we created:

DocumentRoot /var/www/app-name

In total, our virtualhost file should look like this:

<VirtualHost *:80>
    DocumentRoot /var/www/html/app-name/public
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

save and close the file.

2. Enable the Virtual Host File

sudo a2ensite

When you are finished, you need to restart Apache to make these changes take effect:

sudo service apache2 restart

3. Set Up Local Hosts File (Optional)

sudo nano /etc/hosts

hosts file will look something like this   localhost

For the domain that I used in this guide, assuming that my VPS IP address is, if you are creating vhost locally, you can replace with

Now that you have your virtual hosts configured, you can test your laravel app easily by going to the domain that you configured in your web browser:

Install WordPress plugins, themes & upgrades without providing FTP access?

You must have experienced that WordPress asks for FTP credentials if you initiate upgrade or install plugins. And sometimes developers don’t have FTP access and all they have is WordPress admin panel access. Let’s see why WordPress asks for FTP info and how to bypass it and enable WordPress to install updates and plugins without FTP info. Continue reading “Install WordPress plugins, themes & upgrades without providing FTP access?”

Get selected value of radioButtonList using jQuery in Yii

Sometimes you want to get selected value of radioButtonList using jQuery in your Yii powered application and it feels difficult due to Yii’s field naming conventions, as every field name contains array. Continue reading “Get selected value of radioButtonList using jQuery in Yii”

My 3 days trip to Swat, Malam Jabba and Kalam (20th Mar to 23rd Mar)

Pakistan is a land of natural beauty and has been blessed with the abundance of awe-inspiring outdoor areas. From the unspoiled golden beaches,across the desolate desserts and through fertile plains onto the mighty snow capped peaks, Pakistan is the land of many lands. There are few areas in the world where mountains rise in such awesome splendor as they do in the northern areas of Pakistan and I can also acclaimed it now as I experienced it all myself. I started my journey from Lahore to this lavishly adorned area at 20th march 2015 with some of my friends and colleagues. We approached a well-famed local travel agency The Trekkerz for our voyage which gave us three days package of Swat, Malam Jabba and Kalam. Continue reading “My 3 days trip to Swat, Malam Jabba and Kalam (20th Mar to 23rd Mar)” is The Fastest growing real estate startup in Pakistan

There are several online real estate portals running in Pakistan, a couple of them have captured the market and leading the industry. In such a scenario it’s hard to take an initiative to start a parallel venture and compete but’s case is different. They get recognized in very less time and now they are strong competitors of existing giants of real estate industry in Pakistan. Continue reading “ is The Fastest growing real estate startup in Pakistan”

Adding Custom Fields to WordPress User Profile and Add New User page

Adding custom profile fields in WordPress made easy through action hooks. .Most of the solutions available on internet tell you about adding custom fields on “Edit User” screen, in this tutorial I will tell you how to add your custom fields to Add New User screen
Continue reading “Adding Custom Fields to WordPress User Profile and Add New User page”