Thursday, March 10, 2016

Magento Interview Questions and Answers


Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magento intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give merchants the power to create sites that are tailored to their unique business needs.
Here below display basic question and answer in Magento that mostly asked by Interviewer.

Question 1. Which technology does Magento use?

Zend Framework (PHP), MySQL/MySQLI, CSS, javaScript and HTML

Question 2. Mention what are the basic features of Magento?

Basic features of Magento includes
1. Reporting and Analytic
2. Product and Catalog Browsing
3. Customer Accounts
4. Order Management
5. Payment
6. Site Management
7. Shipping
8. Search engine optimization
9. Marketing promotions and tools
10.Checkout
11.International Support

Question 3. Mention what is the limitation of Magento?

1. Magento is supported by PHP, comparatively to other e-commerce solutions, Magento might be slow in performance
2. It becomes a complex system if it is not using object-oriented programming.
3. Magento requires much space and memory.
4. Magento is not recommended for small projects/website.
5. Deep customization requires a better understanding of Magento & it's database table structure etc.

Question 4. How to upgrade to the latest version using Magento connect?

Upgrading Magento to the latest version is a fairly simple task. Copy and Paste this key magento-core/Mage_All_Latest VIA Magento Connect where it states Paste extension key to install:. This will upgrade Magento to the newest version.

Question 5. What is EAV in Magento?

Full form of EAV is Entity Attribute Value model.
EAV is a data model to data model to describe entities.
In EAV data are stored in different smaller tables rather than storing in a single table.
Example :
Product name is stored in catalog_product_entity_varchar table.
Product id is stored in catalog_product_entity_int table.
Product price is stored in catalog_product_entity_decimal table.

Question 6. Explain Magento's MVC architecture.

MVC stands for Model-View-Controller. Any application that separates it’s data access, business logic and user interface is called MVC. There can be two types of MVC: convention-based & configuration-based.
Example:
- CakePHP is convention-based, i.e. you just need to follow the instructions of the core system to get your module ready in just few lines.
- Magento is configuration-based, i.e. you need to specify each and every thing to your module’s config file in order to get it work. Magento has Controller (for Routing), Block (for Business Logic), Model (for DB access, sql) and Template file (for Presentation i.e. View).

Question 7. How does Magento ORM works?

ORM full form is Object Relational Mapping.
ORM is a programming technique which is used to convert different types of data to Objects and vice versa. ORM is shown as Model (based on Zend Framework’s Zend_Db_Adapter), which further breaks down to two types of Models.
1. Simple
2. EAV Model

Question 8. Explain about the modules of Magento.

Magento supports installation of modules through a web-based interface accessible through the administration area of a Magento installation. Modules are hosted on the Magento eCommerce website as a PEAR server. Any community member can upload a module through the website and is made available once confirmed by a member of the Magento team. Modules are installed by entering a module key, available on the module page, into the web based interface.
There are three categories of modules hosted on Magento Connect:
1. Core Modules
2. Community Modules
3. Commercial Modules
Core and Community modules can be installed via the administration area. Commercial module pages provide price information and a link to an external website.

Question 9. How many types of products Magento provide?

1. Simple Products
A Magento simple product is the most used product type for Magento web shops. This is because it’s the most general product type of them all. A Magento simple product should be used for a single item without any specific select variations. Think about a coffee cup, a chandelier, a table or whatever.

2. Grouped Products
A Magento grouped product should be used for a combination of Magento simple products. Think about a coffee cup that is sold together with a saucer, a silver spoon, a breakfast plate or whatever. You can’t define a specific price for a Magento grouped product but you can define a discount amount.

3. Configurable Products
A Magento configurable product should be used for a single item with specific select variations. Think about a coffee cup obtainable in different colors and sizes, a woman’s bag obtainable in different materials, a light boll obtainable in different watts or whatever. Each selected variation can have its own additional costs.

4. Virtual Products
A Magento virtual product should be used for a virtual (not touchable) item. Think about an insurance, a reservation, an extra product guarantee or whatever. A virtual product does not allow selecting a shipping method at checkout simply because there’s nothing to ship.

5. Bundle Products
A Magento bundle product should be used for a bundle of simple (or virtual) products which are not to be sold separately. Think about a laptop where the customer can choose various items such as hard disk, processor, internal memory or whatever. Each of these items are simple (or virtual) products but can only be sold within the bundle product.

6. Downloadable Products
A Magento downloadable product should be used for online software items. Think about an MP3 file, a PowerPoint presentation, a Magento extension or whatever. A downloadable product does not allow selecting a shipping method at checkout simply because there’s nothing to ship.

Question 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.

Question 11. 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.

Question 12. How will you enable maintenance mode of your Magento website?

If you want your Magento website to show in maintenance mode, you will have to do two things.
1. Create a file name maintenance.flag in your Magento root directory. Contents under this file doesn’t matter, you can keep it empty.
2. Change the maintenance file (located in Magento root -> errors -> default directory) to show proper message when user visits your website.

Question 13. How will you enable maintenance mode of your Magento website?

Steps to create custom Magento module:
Namespace : Newsinfo
Module Name : Mymodule
1. Create directory Mymodule in app/code/local/Newsinfo
2. Create Block, controllers, etc, Module directories. Create controller, block and module file as required.
3. Create module configuration file (app/code/local/Newsinfo/Mymodule/etc/config.xml).
4. Create xml file (app/etc/modules/Newsinfo_ Mymodule.xml)to enable/disable module and tell Magento system from which code pool that module will be taken.

Question 14. How to improve Magento performance?

1. Enabled Magento caching
2. MySQL Query caching
3. Enable Gzip Compression
4. Disable any unused modules
5. Disable the Magento log
6. Optimize your images
7. Combine external CSS/JS into one file
8. Enable Apache KeepAlives: Make sure your Apache configuration has KeepAlives enabled.
9. Optimize your Server
10.Use a Content Delivery Network (CDN)

Question 15. Which factors affect performance of Magento?

1. EAV structure of Magento database, even for retrieving single entity the query becomes very complex .
2. Magento’s template system involves a lot of recursive rendering.
3. Huge XML trees built up for layout configuration, application configuration settings.

Question 16. What is Magento's compilation feature?

The Compilation feature of Magento will allow you to compile all files of a Magento installation in order to create a single include path to increase performance. The performance increase is between 25%-50% on page loads. In order to use this tool, the directory 'includes' and the file 'includes/config.php' must both be writable.
Note: Before you make any changes to your Magento installation you should always disable compilation. Once the changes are made, run the compilation process, and then enable it.

Question 17. How indexing works in Magento and why it require?

There are different kind of indexes in Magento. All of the indexers are there to make things run faster.
Flat Index
There are 2 such indexes. One for categories and one for products.
By default the category and product entities (and customers and customer addresses but they are not important in this situation) are EAV entities. This is very nice for extensibility. But it's a performance killer because in order to get all values for all the attributes you need a lot of joins or multiple queries.
Here is where the flat indexer comes into play.
It transforms the EAV structure into a flat structure. I mean it creates a table (one for each store view in Magento) that has one column corresponding to an attribute. This makes selects faster. For categories all attributes are converted to table columns. For products only the ones you mark as 'Used in product listing' because you can sell all types of products with different attributes and creating one table with a gazillion columns may not be possible.
Also, some products may be disabled or may not belong to a certain website and there is no need to include them in the entries to search. They are excluded by the indexer.
The generated flat tables are used for reading data in the fronend. The backend still uses the EAV structure.

Catalog Search Index
You can search for products by many attribute values. Some of them may not be included in the flat tables generated by the flat indexer. This index fills in a table with the searchable attribute values for products so it's easier to look for them based on keywords. Having all the info in one table (or one field) makes it possible to use Full text search and get relevant results.

Product Prices
The price of a product can be affected by many variables. For example, customer group, website, catalog discount rules.
Same as above, getting the products with their prices will mean a lot of joins or multiple selects. IN addition bundle products have a strange pricing system. This indexer aggregates the data in some tables (catalog_product_index_price_*) and makes the selects (sorting and filtering) much easier.

Catalog URL Rewrites
This cleans up the url rewrite rules by setting which url corresponds to which product or category. It's easier this way for the url management internal system to decide which page should you view when calling a non-standard url. Instead of searching through all the product and categories URL keys it just searches in one table.

Category Products
In Magento you can set a category attribute named 'Is Anchor' to true or false. If it's true it means that the category in question will list all the products from it's child categories. Again, determining this realtime it will take more resources than just reading one table. This indexer creates the association between products and categories based on the associations you set in the backend and the 'Is Anchor' flag on the categories.

Stock Status
For simple products it's easy. They can be in stock or out of stock, but for configurable, grouped and bundle is not that easy. They can be in stock or out of stock depending on the child products associated to the main product. Again (I'm just repeating my self here) getting their status real time would mean a lot of queries.

Product Attributes
This one collects all attributes that can be used in the layered navigation for same reason. Having all of them in one place for faster reading.

Tag Aggregation
I have no idea what this does. I've never used tags in a real live project.

Question 18. How to change admin URL of Magento?

There are 2 ways to change admin URL of Magento:
1: Go to app/etc/local.xml file, search for <frontName>tag, replace adminpanel with your new admin url
e.g we have changed the adminpanel URL to adminmagento in below example

<admin>
    <routers>
        <adminhtml>
            <args>
                <frontName><![CDATA[adminmagento]]></frontName>
            </args>
        </adminhtml>
    </routers>
</admin>

2: You can also change Admin URL of Magento in Admin panel of Magento
In your admin panel, go to  System -> Configuration->Advanced ->Admin->Admin Base URL->Use Custom Admin URL, select to  ‘yes’ to use custom admin URL, now enter new admin path in `Custom admin path` field and save it.

Question 19. What is the difference between Mage::getSingletone() andMage::getModel() in Magento?

Mage::getSingletone() always finds for an existing object if not then create that a new object but Mage::getModel() always creates a new object.

Question 20. How find Magento version?

Mage::getVersion(); which is stored in app/Mage.php file.

Question 21. Difference between 'controller' and 'controllers'

The difference is in the auto loading, as you have mentioned. In general files that are in /Controller are Abstract (or parent) classes from which classes in /controllers inherit.

Question 22. How to add an external javascript/css file in Magento?

Add CSS File
<action method="addCss"><stylesheet>css/yourstyle.css</stylesheet></action>
Add JS File
<action method="addJs"><script>js/yourfile.js</script></action>

Question 23. Get Base Url , Skin Url , Media Url , Js Url , Store Url and Current Url.

1. Get Base Url :
Mage::getBaseUrl();

2. Get Skin Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
(a) Unsecure Skin Url :
$this->getSkinUrl('images/imagename.jpg');
(b) Secure Skin Url :
$this->getSkinUrl('images/imagename.gif', array('_secure'=>true));

3. Get Media Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

4. Get Js Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

5. Get Store Url :
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

6. Get Current Url
Mage::helper('core/url')->getCurrentUrl();

Get Url in cms pages or static blocks
1. Get Base Url : {{store url=""}}
2. Get Skin Url : {{skin url='images/imagename.jpg'}}
3. Get Media Url : {{media url='/imagename.jpg'}}
4. Get Store Url : {{store url='mypage.html'}}

Question 24. Type of session in Magento.

customer/session, checkout/session, core/session

Question 25. How to run custom query in Magento?

$db = Mage::getSingleton('core/resource')->getConnection('core_write');
$result=$db->query('SELECT * FROM TABLE WHERE id=1');

Question 26. How to include CMS block in template file(.phtml)?

Access block's content from .phtml template file by :
echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘static_block_id’)->toHTML();

Question 27. How to get the total price of items currently in the cart?

Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal();

Question 28. How to set different themes for logged in users?

if(Mage::getSingleton(‘customer/session’)->isLoggedIn()):
Mage::getDesign()->setPackageName(‘package_name’)->setTheme(‘themename’);
endif;

Question 29. How to fetch 5 bestsellers products pro-grammatically?

Mage::getResourceModel(‘reports/product_collection’)
->addOrderedQty()
->addAttributeToSelect(‘*’)
->setPage(1, 5)
->load();

Question 30. Get all products by category in Magento.

$products = Mage::getModel('catalog/category')->load($category_id)
 ->getProductCollection()
 ->addAttributeToSelect('*') // add all attributes - optional
 ->addAttributeToFilter('status', 1) // enabled
 ->addAttributeToFilter('visibility', 4) //visibility in catalog,search

Question 31. What are the addAttributeToFilter Conditionals in Magento?

In Magento we can use addAttributeToFilter Conditions same as where in SQL.
Below are the all condtions:
Equals: eq
$_products->addAttributeToFilter('status', array('eq' => 1));
Not Equals - neq
$_products->addAttributeToFilter('sku', array('neq' => 'test-product'));
Like - like
$_products->addAttributeToFilter('sku', array('like' => 'UX%'));

One thing to note about like is that you can include SQL wildcard characters such as the percent sign.

Not Like - nlike
$_products->addAttributeToFilter('sku', array('nlike' => 'err-prod%'));
In - in
$_products->addAttributeToFilter('id', array('in' => array(1,4,98)));

When using in, the value parameter accepts an array of values.

Not In - nin
$_products->addAttributeToFilter('id', array('nin' => array(1,4,98)));
NULL - null
$_products->addAttributeToFilter('description', 'null');
Not NULL - notnull
$_products->addAttributeToFilter('description', 'notnull');
Greater Than - gt
$_products->addAttributeToFilter('id', array('gt' => 5));
Less Than - lt
$_products->addAttributeToFilter('id', array('lt' => 5));
Greater Than or Equals To- gteq
$_products->addAttributeToFilter('id', array('gteq' => 5));
Less Than or Equals To - lteq
$_products->addAttributeToFilter('id', array('lteq' => 5));

Question 32. How to get first item or last item from the collection?

$collection->getFirstItem() and $collection->getLastItem();

Question 33. How to convert default currency to others in Magento?

Mage::helper('directory')->currencyConvert($price, USD, GBP);

Question 34. What are 'magic methods' in Magento?

Magento uses __call(), __get(), __set(), __uns(), __has(), __isset(), __toString(), __construct(), etc. magic methods. You can find more details inside class Varien_Object
For more information about magic methods: http://php.net/manual/en/language.oop5.magic.php

Question 35. Explain the difference between Final class and Abstract class?

Final Class:
A Class which Can't be inherited by other class, that class is called final class.
You all knows that final class is inbuilt in java. But in C++ you have to create final class.Two types of Final class, you can create. One who want to create object of final class on Heap and other who wants to create object of Final class on stack.
1. It makes use of private constructor, virtual inheritance and friend class.
2. In place of private constructor, use private Destructor.
Because Constructor can be overloaded and Destructor can't be overloaded.

Wednesday, March 9, 2016

Add Custom Tabs to Magento Product/Customer in Admin Panel


Magento provides the best functionality for managing products from admin panel and also all basic features provide as edit the product. all fields in Magento products group by tab menu. same for customers.
For developer sometimes need to add extra features as a tab in product or customer edit functionality. that time you can create new extension for overwrite Magento functionality or directly edit core files.So here describe basic changes for how to add extra tab menu in product and customer edit screen.
If you want to add product tab in product details than navigate to `app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tabs.php` file and add below code in `_prepareLayout()` function.

$this->addTab('Custom',array(
'label' =>Mage::helper('catalog')->__('Custom'),
'class' =>   'ajax',
'url'   =>   $this->getUrl('*/*/custom',array('_current'=>true)),
));

same for customer add code as below in `app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tabs.php` file and add own file in 'Tab' folder on same location or create custom action in controller file.
Create new extension for that according to Magento extension structure.first create new `Newsinfo_Customtabs.xml` file in `app\etc\modules\` with below code.

<config>
    <modules>
        <newsinfo_customtabs>
            <active>true</active>
            <codepool>local</codepool>
        </newsinfo_customtabs>
    </modules>
</config>

Create `config.xml` file in `app\code\local\Newsinfo\Customtabs\etc\`with below code.

<?xml version="1.0"?>
<config>
  <modules>
    <Newsinfo_CustomTabs>
      <version>0.1.0</version>
    </Newsinfo_CustomTabs>
  </modules>
  <global>
    <blocks>
      <customtabs>
        <class>Newsinfo_Customtabs_Block</class>
      </customtabs>
    </blocks>
    <models>
      <customtabs>
        <class>Newsinfo_Customtabs_Model</class>
      </customtabs>
    </models>
  </global>
  <adminhtml>
    <layout>
      <updates>
        <customtabs>
          <file>customtabs.xml</file>
        </customtabs>
      </updates>
    </layout>
    <events>
      <catalog_product_save_after> //for customer customer_save_after
        <observers>
          <newsinfo_save_product_data> //for customer newsinfo_save_customer_data 
            <type>singleton</type>
            <class>customtabs/observer</class>
            <method>saveProductTabData</method>
          </newsinfo_save_product_data>
        </observers>
      </catalog_product_save_after>
    </events>
  </adminhtml>
</config>

Here below display observer event after save product/customer data.create new `Tab.php` file in `app\code\local\Newsinfo\Customtabs\Block\Adminhtml\Catalog\Product\`(for customer file location `app\code\local\Newsinfo\Customtabs\Block\Adminhtml\Customer\`) as below code.

<?php
class Newsinfo_Customtabs_Block_Adminhtml_Catalog_Product_Tab 
extends Mage_Adminhtml_Block_Template
implements Mage_Adminhtml_Block_Widget_Tab_Interface {
    public function _construct()
    {
 parent::_construct();
 $this->setTemplate('customtabs/tab.phtml');
    }
    public function getTabLabel()
    {
     return $this->__('My Custom Tab');
    }
    public function getTabTitle()
    {
     return $this->__('Click here to view your custom tab content');
    }
    public function canShowTab()
    {
  return true;
    }
    public function isHidden()
    {
     return false;
    }
}?>

Add new `customtabs.xml` file in `app\design\adminhtml\default\default\layout\`.

<?xml version="1.0"?>
<layout>
  <adminhtml_catalog_product_edit>//for customer adminhtml_customer_edit
    <reference name="product_tabs">
      <action method="addTab">
        <name>my_custom_tab</name>
        <block>customtabs/adminhtml_catalog_product_tab</block>
        //for customer adminhtml_customer_tab</action>
    </reference>
  </adminhtml_catalog_product_edit>
</layout>

Create new phtml file in admin panel that you want to display in custom tab.here just display text-box.create `tab.phtml` file in `app\design\adminhtml\default\default\template\customtabs\` as below.

<div>
  <label>Custom Field</label>
  <input name="custom_field" />
</div>

Follow below code and create new extension that displays custom tab in product/category edit section if not display than clear all cache and check again.now create `Observer.php` for save data in `app\code\local\Newsinfo\Customtabs\Model\`as below.

<?php
class Newsinfo_Customtabs_Model_Observer
{
 static protected $_singletonFlag = false;
 public function saveProductTabData(Varien_Event_Observer $observer)
 {
  if (!self::$_singletonFlag) {
   self::$_singletonFlag = true;
   $product = $observer->getEvent()->getProduct(); //For Product
   $customet = $observer->getEvent()->getCustomer(); //For Customer
   try {
    $customFieldValue =  Mage::app()->getRequest()->getPost('custom_field');
   }
   catch (Exception $e) {
    Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
   }
  }
 }
 public function getProduct() //For Product
 {
  return Mage::registry('product');
 }
 public function getCustomer() //For Customer
 {
  return Mage::registry('current_customer');
 }
}
?>

Tuesday, March 8, 2016

Display Category Collection With Toolbar in Magento

Magento provide product listing with Grid view and List view,Order by ascending and descending with pagination functionality which is best and highly designed website functionality but some times you want to implement that toolbar functionality for category collection. For some Magento story design you want to implement sub category listing same as products listing than you must modify Magento core functionality because it not provide this type of functionality.
See below process for create own extension in local pool for display sub category listing with toolbar.
Create new `Newsinfo_Subcategories.xml` file in `app\etc\modules\` as below code.

<?xml version="1.0"?>
<config>
    <modules>
        <Newsinfo_Subcategories>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Catalog />
            </depends>
        </Newsinfo_Subcategories>
    </modules>
</config>
 
Create new `config.xml` file in `app\code\local\Newsinfo\Subcategories\etc\`as below code.

<?xml version="1.0"?>
<config>
    <modules>
        <Newsinfo_Subcategories>
            <version>1.0.0</version>
        </Newsinfo_Subcategories>
    </modules>
    <global>
        <blocks>
            <grbrains>
                <class>Newsinfo_Subcategories_Block</class>
            </grbrains>
        </blocks>
        <helpers>
            <grbrains>
                <class>Newsinfo_Subcategories_Helper</class>
            </grbrains>
        </helpers>
    </global>
</config> 

create new `Data.php` file in`app\code\local\Newsinfo\Subcategories\Helper\` with class as below.


class Newsinfo_Subcategories_Helper_Data extends Mage_Core_Helper_Abstract
{
   //Enter helper data functions.
 }
create new `Subcategories.php` file in `app\code\local\Newsinfo\Subcategories\Block\`that display subcategories on fronted as below code.

class Newsinfo_Subcategories_Block_Subcategories extends Mage_Core_Block_Template
{
    public function __construct()
    {
        parent::__construct();
        $category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
        $collection = Mage::getModel('catalog/category')->getCollection();
        $collection->addFieldToFilter('parent_id',$category->getId());
        $collection->addIsActiveFilter();
        $collection->addNameToResult();
        $collection->addUrlRewriteToResult();
        $this->setCollection($collection);
    }
    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $parent_id = Mage::app()->getStore()->getRootCategoryId();
        if($this->getRequest()->getParam('category_id',false)){
            $parent_id = $this->getRequest()->getParam('category_id');
        }
        $category = Mage::getModel('catalog/category')->load($parent_id);
 
        if ($headBlock = $this->getLayout()->getBlock('head')) {
            if ($title = $category->getMetaTitle()) {
                $headBlock->setTitle($title);
            }
            if ($description = $category->getMetaDescription()) {
                $headBlock->setDescription($description);
            }
            if ($keywords = $category->getMetaKeywords()) {
                $headBlock->setKeywords($keywords);
            }
        } 
        $toolbar = Mage::getBlockSingleton('catalog/product_list')->getToolbarBlock();
  $pager = $this->getLayout()->createBlock('page/html_pager', microtime());
        $toolbar->setChild('product_list_toolbar_pager', $pager);
        $collection = $this->getCollection();
        if ($orders = $this->getAvailableOrders()) {
            $toolbar->setAvailableOrders($orders);
        }
        if ($sort = $this->getSortBy()) {
            $toolbar->setDefaultOrder($sort);
        }
        if ($dir = $this->getDefaultDirection()) {
            $toolbar->setDefaultDirection($dir);
        }
        $toolbar->setCollection($collection);
 
        $this->setChild('toolbar', $toolbar);
  
        $this->getCollection()->load();
        return $this;
    }
    public function getDefaultDirection(){
        return 'asc';
    }
    public function getAvailableOrders(){
        return array('name'=> 'Name','position'=>'Position','children_count'=>'Sub Category Count');
    }
    public function getSortBy(){
        return 'position';
    }
    public function getMode()
    {
       return $this->getChild('toolbar')->getCurrentMode();
    }
    public function getToolbarHtml()
    {
        return $this->getChildHtml('toolbar');
    }
 public function getPagerHtml()
    {
        return $this->getChildHtml('pager');
    }
}

Now it's ready for call in website here display all sub category listing than first create new static block from Admin->CMS->Static Blocks->Add New Block with below details.

Block Title : Sub Categories
Identifier : subcategories
Status : Enable
Content :{{block type="newsinfo/subcategories" template="catalog/category/subcategory.phtml"}}

Save below block and  set block permission from Admin->System->Permission->Blocks and create new block with name as`newsinfo/subcategories` and status as `Allowed`.
Now call created static block on any category from Admin->catalog->Manage Categories->CATEGORY->Display Settings set `Display Mode` as `Static block only` and `CMS Block` as  'Sub Categories' (created as below).
Now create `subcategory.phtml` file in `app\design\frontend\THEME\default\template\catalog\category\` as below code.

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php $collection = $this->getCollection(); ?>
<?php echo $this->getToolbarHtml(); ?>
<?php if($collection->getSize()): ?>
  <?php if($this->getMode()!='grid'): ?>
  <!-- List Model -->
  <?php $_iterator = 0; ?>
  <ol class="products-list" id="products-list">
    <?php foreach ($collection as $category):
        $category = Mage::getModel('catalog/category')->load($category->getId()); ?>
    <li class="item<?php if( ++$_iterator == sizeof($collection) ): ?> last<?php endif; ?>"> <a href="<?php echo $category->getUrl() ?>" title="<?php echo $this->stripTags($category->getName()); ?>" class="product-image"><img src="<?php echo $category->getImageUrl();?>" alt="<?php echo $this->stripTags($category->getName()) ?>" /></a>
      <div class="product-shop">
        <div class="f-fix">
          <?php $_productNameStripped = $this->stripTags($category->getName(), null, true); ?>
          <h2 class="product-name"><a href="<?php echo $category->getUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $category->getName(); ?></a></h2>
          <div class="desc std"> <?php echo $category->getDescription(); ?></div>
        </div>
      </div>
    </li>
    <?php endforeach; ?>
  </ol>
  <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
  <?php else: ?>
  <!-- Grid Mode -->
  <?php $_collectionSize = $collection->count() ?>
  <?php $_columnCount = $this->getColumnCount();if(!$_columnCount){$_columnCount = 3;}?>
  <?php $i=0; foreach ($collection as $category):
    $category = Mage::getModel('catalog/category')->load($category->getId());?>
  <?php if ($i++%$_columnCount==0): ?>
  <ul>
    <?php endif;?>
    <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
      <div class="product-bdr-area">
        <div class="product-img-area"> <a href="<?php echo $category->getUrl() ?>" title="<?php echo $this->stripTags($category->getName()); ?>" class="product-image"><img src="<?php echo $category->getImageUrl()?>" alt="<?php echo $this->stripTags($category->getName()) ?>" /></a> <a href="<?php echo $category->getUrl() ?>" title="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a> </div>
      </div>
    </li>
    <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
  </ul>
  <?php endif ?>
  <?php endforeach ?>
  <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
  <?php endif; ?>
<?php else: ?>
<p class="note-msg"><?php echo $this->__('There is no sub category'); ?></p>
<?php endif ?>

Install Laravel Framework on WAMP(Windows) Server

Laravel is a free, open-source PHP framework created by Taylor Otwell on June 2011.It's use for developing web application based on Model View Controller (MVC) patten.There are many others PHP based frameworks likes Codeigniter, Symfony, Yii and many more but Laravel is most famous and used framework on 2015.It's easy for this framework install in linux server.
Here describe some basic steps for install laravel on window (WAMP) server and configure that.follow below steps for that.
  • Download Laravel latest version form Github (Check your PHP version configuration for that).
  • Extract all directory and files in your WWW folder on WAMP.
  • Enable OpenSSLfrom Wamp icon->PHP->Php extensions `php_openssl` and Wamp icon->Apache->Apache modules `ssl_module`
  • You can also enable ssl from php.ini file in `C:\wamp\bin\php\{PHPVersion}\` and apache `C:\wamp\bin\apache\{ApacheVersion}\bin`find `;extension=php_openssl.dll` and remove preceding semicolon (if there is).
  • Download Composer exe file setup from Here.
  • Run setup file and click on next (Select Shell Menus option).
  • Than enter `php.exe` file location path as  `C:\wamp\bin\php\{PHPVersion}\php.exe`.
  • Open CMD(Command Line Interface) window using  Ctrl+R and enter 'cmd'.
  • Enter directory where you install Laravel using CD command `C:\wamp\www\laravel`
  • Now run below code in cmd window.
    composer create-project laravel/laravel NEWPROJECT --prefer-dist
  • This will install Laravel in a sub directory named NEWPROJECT under current working directory.
Most of common error display in Laravel 5 is 'Failed opening required bootstrap/../vendor/autoload.php'.
This error display when Laravel dependency not installed properly. that time delete all data in newly created directory 'NEWPROJECT ' and open cmd navigate to Laravel directory and run below command.
composer create-project laravel/laravel NEWPROJECT