Thursday, 31 May 2018

Magento 1 : Hide other shipping methods when free shipping is available

To prevent other shipping options to display when Free Shipping is available, add the following code to your template:

Open :

if ( array_key_exists('freeshipping', $_shippingRateGroups )) {

Then ,  flatrateperproduct Method will be remove from the shipping method.

Tuesday, 15 May 2018

How to add Buy Now At Product Page in Magento - 1 version ?

If you want both Add to Cart and Buy now, add the buy now button to addtoCart.phtml

Go to
/app/design/frontend/[package name]/[themename]/template/ajaxcart/catalog/product/view/addtoCart.phtml

<button type="button" 
        title="<?php echo $buttonTitle ?>"
        class="button btn-cart" 

On that buttons onlick event, a custom VarienForm is used, productBuyNowForm.submit(this), which will submit this form and redirect to checkout onepage.

To define this custom form, add the following JavaScript code at view.phtml

Go to
/app/design/frontend/[package name]/[theme name]/template/catalog/product/view.phtml

var productBuyNowForm = new VarienForm('product_addtocart_form');
productBuyNowForm.submit = function (button, url) {
    if (this.validator.validate()) {
        var form = this.form;
        var oldUrl = form.action;
        if (url) {
            form.action = url;

        /* add return Url */
        var inputreturn= document.createElement("input");
        inputreturn.type = "hidden"; = "return_url";
        inputreturn.value = "<?php echo Mage::getUrl('checkout/onepage')?>";
        /* add return Url */
        // Append a line break 
        var e = null;
        try {
        } catch (e) {
        this.form.action = oldUrl;
        if (e) {
            throw e;

        if (button && button != 'undefined') {
            button.disabled = true;


Saturday, 1 July 2017

How to add custom attribute for category

Follow bellow steps

Step : 1 app\etc\modules\TEJA_Dbchange.xml

    <?xml version="1.0"?>

Step : 2 app\code\local\TEJA\Dbchange\etc\config.xml

    <?xml version="1.0"?>

Step : 3 app\code\local\TEJA\Dbchange\sql\teja_dbchange_setup\mysql4-install-0.1.0.php

    $installer = $this;
    $attribute  = array(
        'group'                     => 'General',
            'input'                     => 'select',
            'type'                      => 'int',
            'label'                     => 'Testing',
            'source'                    => 'eav/entity_attribute_source_boolean',
            'global'                    => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'visible'                   => 1,
            'required'                  => 0,
            'visible_on_front'          => 0,
            'is_html_allowed_on_front'  => 0,
            'is_configurable'           => 0,
            'searchable'                => 0,
            'filterable'                => 0,
            'comparable'                => 0,
            'unique'                    => false,
            'user_defined'              => false,
            'default'           => '0',
            'is_user_defined'           => false,
            'used_in_product_listing'   => true
    $installer->addAttribute('catalog_category', 'testing', $attribute);

Step : 4 After refresh all magento cache by going System -> Cache Management
Step : 5 Logout  and login again.

Wednesday, 21 June 2017

What is the difference between convention and configuration?

  1. Configuration - would have been manually mapping controllers to use specific views, almost like a code behind scenario.
  2. Convention - A Controller method named Index most likely wants to use a View called the same, so the framework goes and looks for that.

Wednesday, 14 June 2017

Difference among Order Invoice, Cancel, Void, Hold and Ship in Magento

Pending. - Placing new order. it is default status is pending

Processing - You are raise a invoice from Magento admin status is change to

On Hold - This status can only be assigned manually. You can put any order on hold.

Cancelled - This status is assigned manually by you or, on some payment gateways, when customer does not pay within the specified time.

Complete - This status means that order is crated, paid and shipped to customer.

Closed - Closed orders are orders that have had a credit memo assigned to it and the customer has been refunded for their order.

Pending Payment - This is the status used if order is created and PayPal or similar payment method is used. This means that customer has been sent to payment gateway website but no return information has been received yet. This status will change when customer pays. Some gateways do cancel abandoned orders automatically after some 'idle' time. If order had this status for a long time, you should cancel it manually to free product stock.

Wednesday, 22 March 2017

How to access localhost website from another computer on the same network?

To access the localhost websites from another computers in a same network, need to follow these steps :
  1. Set up a virtual host
  2. Configure your hosts file
Set up a virtual host
You first need to set up a virtual host in your apache httpd-vhosts.conf file. On XAMP, you can find this file here: C:\xampp\apache\conf\extra\httpd-vhosts.conf This step prepares the Web server on your computer for handling symfony.local requests. You need to provide the name of the Virtual Host as well as the root/main folder of your website. To do this, add the following line at the end of that file. You need to change the DocumentRoot to wherever your main folder is. Here I have taken /Applications/MAMP/htdocs/Symfony/ as the root of my website.

<VirtualHost *:80>
    DocumentRoot "/Applications/MAMP/htdocs/Symfony/"
    ServerName symfony.local

Configure your hosts file:

For the browser understand what symfony.local really means,
you need to edit the hosts file on your computer.

(if you're using WINDOWS 7, this file is in

# Host Database
# localhost is used to configure the loopback interface
#...           symfony.local

Thats it. Now the configuration is completed.
Note: you should replace the above ip address with your system ip address.
Finally, you have to change the base secure and unsecure urls in
database at
core_config_data table.
Then your url will be change from http:localhost/project

Tuesday, 21 March 2017

Warning: a form on this page has more than 1000 fields PHP MySql

Warning: a form on this page has more than 1000 fields PHP MySql

After reaching so many entries PhpMyAdmin started showing this warning:

Warning: a form on this page has more than 1000 fields. On submission, some of the fields might be ignored, due to PHP's max_input_vars configuration.


For this, I have added the following lines at the bottom of php.ini file.

max_input_vars = 5000

suhosin.request.max_vars = 5000 = 5000

Saturday, 18 March 2017

Magento Vs Open cart

Magento Vs. Opencart – The similarities

Generally, Magento and OpenCart actually have a lot in common.

 1. They are both open source platforms that are ultimately designed to facilitate eCommerce activity.
 2. Both are developed in PHP and use templates to upload products, so they can be maintained by non-programmers.
 3. They are also rich in resources such as extensions, add-on products and plugins that can easily be added to them to support new functions.
 4. One of the greatest advantages that both Magento and Open Cart users enjoy is their ability to support multiple languages and currencies, making them a global solution that can suit businesses all around the world.

Some Market Share Figures

In terms of Market share,

 1. Magento is definitely bigger, with about 30% of top eCommerce websites being built on Magento, making it the largest eCommerce platform in the world.
 2. Open cart may be a lot smaller and newer on the market, but that doesn’t mean it falls in quality.
 3. Magento is the most popular open source e-commerce platform among sites ranking in the top 1,000,000 such websites in the world.
 4. Only when counting all open source e-commerce websites in the entire Internet does Magento fall to second behind Open Cart.

Hosting Plans and Options

 1. Open cart in this case will be cheaper to host thanks to its light weight, and will tend to work better for small to medium size stores.
 2. Magento performs better in hosting medium to large sized business websites.

Usage and Features

Magento :
  • Magento has been gaining world wide recognition for its ability to do just about anything you like and build the store of your dreams.
  • It offers highly customizable shopping experiences, unlimited design options, powerful SEO resources and unlimited plugins and integrations.
  • Every feature you can think of was probably built already and is available on MagentoCommerce. If its not on there, then surely a talented and certified Magento developer can create that solution for you.
  • With it’s flexibility comes also its complexity, which probably isn’t a problem if you’re a Magento developer and know what you’re doing. If you’re not a Magento developer or if you don’t know PHP, you’ll probably find Magento a bit too complex, especially when it comes to taking advantage of its flexibility and custom features.

OpenCart :

  • OpenCart on the other hand is a lot easier to program, but has a smaller community basis.
  • Its great for start-ups that need to deliver quickly without many integrations.
  •  It provides a powerful shopping cart and some great tools which are far more intuitive and straight forward, so much so that some professional developers may find it a bit too simplistic, with not enough features to play with. It’s a bit like comparing between WordPress and Wix, or Microsoft Office Picture Manager and Adobe Photoshop.

Community Support

Both Magento and OpenCart have well-established developer communities that offer support and advice by demand, but obviously the Magento community is far more robust. Magento also certifies and recommends developers to grant them with credibility, which makes it easy to filter the advice you receive and know who you should listen to. We expect that overtime, as Opencart continues to grow, more tutorials and resources will become available, and the number of users that can provide online support will increase.


 1. Magento is great for larger stores with larger budgets. Its got scale-ability to support the growth of your business for years to come, and support any need you may have in the future.
 2. Open cart is more suitable if you’re trying to build your store independently because its more intuitive, and its (almost) free to use, but take into consideration that one day, your business may grow out of it. Whichever your choose- we wish you luck with your new business!

Top Magento Interview Questions & Answers

1) Mention what is Magento?
Magento is an e-commerce platform created on open source technology, which provides online merchants with an exceptional flexibility and control over the content, look and functionality of their e-commerce store.
2) Mention what is the architecture of Magento? What are the different versions of Magento?
Magento architecture is a typical PHP MVC (Model-View-Controller) application, where all the Controllers will be in one folder and all the Models in another, etc.  Based on their functionality files are grouped together, which are referred as modules in Magento.
Different version of Magento includes
  • Magento Enterprise
  • Magento .go
  • Magento Community
3) Mention what technology does Magento use?
Magento use PHP as a web server scripting language and MySQL for database.
4) Mention what is the difference between Mage::getModel() and Mage::getSingletone() in Magento?
  • Mage::getModel(): It always creates a new object
  • Mage: :getSingleton(): It always look for an existing object and if not then creates a new object
5) Mention what are the basic features of Magento?
Basic features of Magento includes
  • Reporting and Analytics
  • Product and Catalog Browsing
  • Customer Accounts
  • Order Management
  • Payment
  • Site Management
  • Shipping
  • Search engine optimization
  • Marketing promotions and tools
  • Checkout
  • International Support
6) Mention what is the limitation of Magento?
  • Magento is supported by PHP, comparatively to other e-commerce solutions, Magento might be slow in performance
  • It becomes a complex system if it is not using object-oriented programming
  • Magento requires much space and memory
7) Explain how you can enhance the Magento performance?
To enhance the Magento performance
  • Disable the Magento log
  • Combine external CSS/JS into one file
  • Disable any unused modules
  • MySQL Query Caching
  • Enable Magento caching
  • Enable Gzip compression
  • Optimize your image
8) Explain how you can show a certain number of products for guests in Magento?

In the toolbar block you will see
there is a method:
Public function setCollection($collection);
Inside there is a piece of code:
$limit= (int)$this->get Limit();
If ($limit) {
$this ->_collection->setPageSize($limit);
You have to change variable $limit; you should override that block in the local pool, not change directly in the core.  In order to see whether the customer is a guest, you can use this code
Mage:: getSingleton(‘customer/session’) -> isLoggedIn()

9) Mention what all billing information can be managed through Magento?
From the client Magento account, you can do following things
  • Update your billing address
  • Add a credit card
  • View your billing history
  • Add a PayPal account
  • Produce a print ready receipt
10) Explain how you can change Magento Core API settings?
To change Magento Core API settings, you have to
  • Go to Admin menu, choose System -> Configuration
  • Select Magento Core API on the left side of the Configuration Panel, under Services
  • Tap on to expand the General Settings section and you can
  • Type the name of the Default Response Charset that you want to use
  • Determine the Client Session Timeout in seconds
  • Click the Save Config button when complete
11) Explain how Magento can be made more secure for the client?
Best practices for Magento includes
  • Using a strong password and changing them at regular interval
  • Disable remote access to Magento Connect Manager
  • Disable Downloader on production sites
  • Restrict access to safe IP addresses
12) Mention what is the benefit of applying Connect Patches in Magento?
In Magento, applying connect patch
  • It enables easy installation of packages with installation; it overwrites any existing translations for the same time
  • For enhancing security, by default Magento Connect uses HTTP to download extensions instead of FTP
  • With a dash character in the name, extension developers can now create extensions
  • Magento administrators will be informed now who tries to install an extension with insufficient file system privileges
13) Explain how you can move Magento to another Directory?
To move Magento to other Directory you have to follow the following steps.
  • Suppose you have Magento installed in the following location
  • On visiting your site, you want Magento to be the first thing to come up
  • Let assume you have a directory structure like this
  • Which means Magento would be installed here
  • Login to the backend of the Magento first and go to
System -> Configuration -> Web
Update the Secure and Unsecure URL for your store and then link to your site via SSH and then go to the directory, where you will be shifting Magento
cd public_html/
  • Now, transfer all the files from the store directory to the directory you are in
mv store/* store/.htaccess
  • Delete the cache data
rm –vf var/cache/
Now Magento is moved to another directory.

14) Explain how you can reset Magento file & Directory permissions?
You can reset Magento file & Directory to their default and secure permissions, by following commands from the directory where Magento is installed
find . –type f –exec chmod 644 {} \;
find . –type d –exec chmod 755 {} \;
chmod +x mage

15) Explain how you can configure Magento to work with another domain?
To do that, in the admin area, you have to change the Magento Base URL option. To do this, visit to your Magento admin area> System > Configuration and click Web on the left menu. Select the Unsecure option after that edit the base URL field to change the URL that will be used for normal (HTTP) connections.

16) Why to use Magento?

The uses of Magento are:
Magento is open source E-commerce software.
it is scalable and offers small companies to build business.
It provides the searching and sorting of products in several ways.
Easily integrates with many of the third-party sites which are needed to run effective E-commerce website.
Using this, customer can order or purchase number of products. There are no limits on number of purchasing products.

17) List the Web-Hosting sites of Magento?

The Web-Hosting sites of Magento are:
  • SiteGround
  • BlueHost
  • HostGator
  • Inmotion
  • Arvixe
  • site5
18) What are disadvantages of Magento?

  • Magento uses larger disk space and memory.
  • It takes much time to build the customized functionality.
  • It is very slow compared to other E-commerce sites.
  • It needs proper hosting environment, if the hosting environment is improper the user can face the problems.
19) Name the web-server that supports Magento?

The Web-server that supports Magento are:
  • Apache 2.x
  • Nginx 1.7.x
20) What are Magento products?

Products are the items or things that are sold in Magento. Product can be anything that is capable of satisfying customer needs. This includes both physical products and services.

21) Name the product types that are available in Magento?

The product types available in Magento are:
  • Simple Products
  • Grouped Products
  • Configurable Products
  • Virtual Products
  • Bundled Products
  • Downloadable Products
22) What is Inventory?

Inventory allows setting a product's stock quantity. For instance, you have a product with 100 units in stock. If you set the stock availability to "Out of Stock" then it will force the item to be out of stock.

23) Name the categories of E-Commerce?

The categories of E-Commerce are:
  • Business to Business(B2B)
  • Business to Consumer(B2C)
  • Consumer to Consumer(C2C)
  • Consumer to Business(C2B)
24) What does Rate Percent mean in Manage Tax Rate window?

Rate Percent specify the percent of the tax rate.
25) What does Priority field specifies in Manage Tax Rules?

Priority field specifies when the tax should be applied to other tax rules.

26) What is the used of Zero Subtotal Checkout panel?

The Zero Subtotal Checkout panel is a payment option that displays when order total is zero and not required to enter payment details for the customer.

27) What is the used of 3D Secure Card validation field in Saved CC?

It is additional security functionality where customer needs to provide credit card password to complete the purchase order.

28) Which are the methods of PayPal Payment Gateways?

The two methods of PayPal Payment Gateways are:
  • Payflow Pro (Includes Express Checkout)
  • Payflow Link (Includes Express Checkout)
29) What is Payflow Pro?

The Payflow Pro option is customizable payment gateway which can be used with merchant account to process credit card transactions.

30) What is Payflow Link?

Payflow Link option often called as hosted payment gateway that keeps customer on your site by providing fast and easy way to add transaction processing to your site.

Friday, 17 March 2017

Delete All URL Rewrites In Magento-1 (Truncate all existed url i magento)

You may wish to delete all URL rewrites from URL Rewrite Management in Magento at some point, especially if you are frequently importing/exporting product and category data.

By using this following SQL Query.

  • TRUNCATE TABLE `core_url_rewrite`;

Wednesday, 1 March 2017

How to apply schedule for themes in magento-1 and magento-2 ?


1) Login to Admin panel

2) Go to Content > Design > Schedule

3) Click on “Add new Design” theme

4) Select the theme,start date, from date and save the design theme


1) Login to Admin panel

2) Go to Content > Design > Schedule

3) Click on “Add new Design” theme

4) Select the theme,start date, from date and save the design theme

Thursday, 20 October 2016

How to reinstall magento engine without reuploading files in magento-1 ?

1) Login to database at phpmyadmin.

2) empty particular database or drop all tables.

3) Goto app->etc folder and remove local.xml file.

4) Start installation by run your url.

How to Change default homepage in magento-1 ?

Go to

 Admin -> System -> Configuration -> General (Left) -> Web > Default Pages ->  CMS Home Page

Select your required home page from drop-down.

You will have to change to the website / store view that you want to change (the drop down in the upper left corner).