Create configurable product in Magento programmatically

Following post includes the code that can be used to create a configurable product in Magento.

Brief introduction about configurable product

When adding new products to your Magento store you have the option to select the type of the product. The most basic option is simple product.
That’s just a single item with no specific attributes/options that can be changed by the buyer.
With the configurable product type you can offer an item with some options that can be configured by the customers themselves.
For example, you can sell the same model of shoes that are offered in different colors, sizes, etc. Instead of creating several simple
products for each size of the same shoe model that will be displayed individually on the frontend,
for instance, you can create a configurable product which will allow the customer to select the size before ordering the product.

To understand the code, one must have a basic understanding of how configurable product works in a Magento store.

Continue reading

Create Simple Product in Magento Store Programmatically


We are creating a simple product programmatically in Magento Store. There is nothing much to describe in this post.
I am using the basic required information to create the product. May be your store needs more attributes to create the product, but to keep the post simple I am using just 2 custom created attributes.




Following script contains a function that gives the option id of option label for any attribute code.
For example, Magento needs the 321(assume option id for label “Black”) to save the value of attribute color.

Continue reading

Configure Redis Server in Ubuntu – Caching Server For Magento

Redis – Server :-
REDIS is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. Redis works with an in-memory dataset.

Redis-Server Installation on Ubuntu:

Execute below commands in /tmp directory.
-> wget
-> tar xvzf redis-stable.tar.gz
-> cd redis-stable
-> make

First Install Redis Cache Extension:
-> git clone
-> mv Cm_Cache_Backend_Redis/Cm app/code/community
-> rm -rf Cm_Cache_Backend_Redis

Then Install Redis Session Extension:
-> git clone
-> mv credis lib/Credis
-> git clone
-> mv Cm_RedisSession/code/ app/code/community/Cm/RedisSession
-> mv Cm_RedisSession/Cm_RedisSession.xml app/etc/modules/Cm_RedisSession.xml
-> rm -rf Cm_RedisSession

Just after <global> add, change persistent and db to suit.
Add below lines in app/etc/local.xml


Check whether Redis-Server is correctly configured.
Execute the following commands in ssh.

root@ip:~# redis-cli (Enter)
redis> KEYS *

2) “zc:k:mage_LAYOUT_12B8E4E9B9664A88F620395C2B0E265C3″
3) “zc:ti:mage_PRODUCT_31489″
4) “zc:k:mage_LAYOUT_102DAFD20DE438A6CCEAB14C14CBD43E6″
5) “zc:k:mage_LAYOUT_12C9CC1468A49CEAAD89B704922CFA00D”
6) “zc:ti:mage_PRODUCT_32386″
7) “zc:k:mage_LAYOUT_145900AB7F6D4CEB9F4C7CDA3C3FDB3E0″
8) “zc:k:mage_Zend_LocaleL_en_GB_day_”
9) “zc:k:mage_LAYOUT_1570BAB63946016D4308F3846E31F3298″
10) “zc:k:mage_LAYOUT_1A81FEA2A13A548546F8C44C45F291E58″
11) “zc:k:mage_LAYOUT_178D667D0447D0D68CE44FA446B549C57″
12) “zc:k:mage_LAYOUT_1D9AB3A02AE7912CCD665FA0A14082DFE”
13) “zc:k:mage_LAYOUT_1EC736E7B6D5E1342588C904A476EF7A4″
14) “zc:ti:mage_PRODUCT_528″
15) “zc:ti:mage_PRODUCT_5001″
16) “zc:k:mage_LAYOUT_180058FA3A3E7ADD27514DD63BF803443″
17) “zc:k:mage_LAYOUT_149B9701C3A642D6FADE5A8C5EFAB3A53″
18) “zc:ti:mage_PRODUCT_5004″
19) “zc:k:mage_LAYOUT_1747906323D5671235BF2A45136D30FE6″
20) “zc:k:mage_LAYOUT_1F48BF80A73C5CDACE114DBC9168A79F9″

This should be the output.
If you are getting above output then Redis-Server is configured correctly and running. And above count should increase continuously.

For more reference :

How To Configure Varnish Cache In Magento With Ubuntu

Varnish Cache is one of the fastest known cache technology.. The technical principle of Varnish is that a user hits the Varnish server first before the request gets redirected to the web server if no cache version is available. If Varnish has found a cached version of the requested URL , the page will be delivered directly from the ram which takes only some milliseconds. The response time will be around 35 milliseconds + latency.

Step one : Installation of Varnish Server On Ubuntu 12.04 :
The varnish site recommends installing the varnish package through their repository.
Start the process by grabbing the repository:
*(Keep in mind that you are a root user while executing the below commands and if you are not root then use sudo in all the lines)

1.curl | sudo apt-key add - /etc/apt/sources.list
Inside the file, add varnish repository to the list of sources.
deb lucid varnish-3.0
3. Finally, update apt-get and install varnish.
apt-get update
apt-get install varnish

Step Two : Configure Varnish

Once you have both nginx and varnish installed, you can start to configure them to ease the load on your virtual private server.
Varnish will serve the content on port 80, while fetching it from nginx which will run on port 8080.

1. Edit /etc/default/varnish file.

Find the lines under “DAEMON_OPTS”— in the Alternative 2 section, and change the port number by “-a” to 80. The configuration should match the following code:

DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Save and exit.

Step Three : Configuring Nginx
Edit the vhost file as shown below
vi /etc/nginx/sites-available/your.vhost
## listen for ipv4;
this line is default and implied [...]


Step Four : Restart Nginx and varnish.
service nginx restart
service varnish restart

Then check your browser.
If its still not working,try below commands

service nginx stop
service varnish restart
service nginx start

Check varnish by following commands.

Pheeww! Sit back,relax and check your website’s performance.