Monday, March 30, 2015

Ajax request , response using jQuery

Ajax request , response using jQuery


<a onclick="callController();" href="javascript:void(0)">View More Articles</a>

<script type="text/javascript">
function callController(){
    
       new Ajax.Request("REQUEST FILE PATH HERE", {
           method: 'Post',
           parameters: {"pg_num":"<?php echo '1';?>"},
           onComplete: function(transport) {
            alert(transport.responseText);
           }
       });
   }
</script>

Thursday, March 26, 2015

jQuery:Tab Hide show

<ul class="tab-cat-name">
    <li>
        <a class="" href="javascript:void(0)" onclick="ShowHideTab('1')">Tab1</a>
        <a href="javascript:void(0)" onclick="ShowHideTab('2')" class="active">Tab2</a>
    </li>
</ul>
<div id="show_hide_1" class="tab-listing" style="display: none;">           
Content1
</div>
<div style="" id="show_hide_2" class="tab-listing">
Content2
</div>
       
<script type="text/javascript">
function ShowHideTab(current){
    jQuery( ".tab-listing" ).each(function( index ) {
        var toshow= index+1;
            if(current==toshow){
            jQuery('#show_hide_'+toshow).fadeIn(1000);
            }else{
            jQuery('#show_hide_'+toshow).fadeOut(1000);
            }
 });
}  
</script>

Tuesday, March 17, 2015

Magento - Magento Interview Questions and Answers

Twelve important questions and answers in Magneto .


Q 1. What is the difference between Mage::getSingletone() andMage::getModel() in Magento
Ans. Mage::getSingletone() always finds for an existing object if not then create that a newobject but Mage::getModel() always creates a new object.


Q 2. Why Magento use EAV database model ?

Ans. In EAV database model, data are stored in different smaller tables rather than storing in a single table. product name is stored in catalog_product_entity_varchar tableproduct id is stored in catalog_product_entity_int tableproduct price is stored in catalog_product_entity_decimal tableMagento Use EAV database model for easy upgrade and development as this model give smore flexibility to play with data and attributes.




Q 3. How to upgrade to the latest version using Magento Connect?
Ans. 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.

Q 4. Explain about the Modules of Magento?
Ans. 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:
  • Core Modules
  • Community Modules
  • 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.

Q 5. How to include CMS block in template file(.phtml)?
Ans. Access block’s content from .phtml template file by :
echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘static_block_id’)->toHTML();


Q 6. How to get the Total Price of items currently in the Cart?

Ans. helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/cart’)->getQuote()->getGrandTotal()); ?>

Q 7. How to set different themes for logged in users?
Ans. if(Mage::getSingleton(‘customer/session’)->isLoggedIn()):
Mage::getDesign()->setPackageName(‘package_name’)->setTheme(‘themename’);
endif;

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

Q 9. How to set different themes for each store?
Ans. Go to : System>Designs
Then, add new design change or edit existing. You can select Store and Custom Design.

Q 10. How to make product’s custom attribute searchable in adavance search?
Ans. Go to : Catalog > Attribues > Manage Attribues
Edit the attribute and select “Yes” for Use in Advanced Search.

Q 11.   How to run custom MySql query in Magento ? Ans. - $db = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’);
- $result=$db->query(“SELECT * FROM PCDSTable”); 

Q 12. What is the difference between Mage::getSingletone() andMage::getModel() in Magento
Ans. - Mage::getSingletone() always finds for an existing object if not then create that a newobject but Mage::getModel() always creates a new object.

Njoy :)