• Magento

    How to change page layout in Magento

    In this post,you can change page layout in Magento also set a Magento page template layout How to change page layout in Magento There are in few steps,you can page pay layouts. For change the page layout,you need to change root block  template(<reference name=”root”>) using setsetTemplate() method  ,So use <action method=”setTemplate”><template>YourPageLayoutLocation/YourLayput.phtml</template></action> and apply this template by  <action method=”setIsHandle”><applied>1</applied></action>   <?xml version="1.0"?> <layout version="0.1.0"> ....... <HandlerName> <reference name="root"> <action method="setTemplate"><template>YourPageLayoutLocation/YourLayput.phtml</template></action> <action method="setIsHandle"><applied>1</applied></action> </reference> </HandlerName> [...] </layout>   Suppose i am changing template   in checkout cart page <checkout_cart_index translate="label"> <reference name="root"> <action method="setTemplate"><template>page/2columns-left.phtml</template></action> <!-- Mark root page block that template is applied --> <action method="setIsHandle"><applied>1</applied></action> </reference> </checkout_cart_index>  

  • Magento

    Create an magento extension with custom database table

    Create an magento extension with custom database table For,a newcomer magento developer,it is not easy to create an magento extension with custom database. There are few steps to create an extension. First of all create module control file Module name as Amit_Custommodule.xml at app/etc/modules/. Which is enabling and disabling that custom module.First of all define CodePool of extension. There are two type of codePool one local another community. Suppose i am using community.Then the code of Amit_Custommodule.xml are: <?xml version="1.0"?> <config> <modules> <Amit_Custommodule> <codePool>community</codePool> <active>true</active> </Amit_Custommodule> </modules> </config> Create a config.xml ,where we are declared table,model,blocks,layouts file , controllers,In a word we can say configuration file that extension. Path Of…

  • General

    Get geo location of an iOS and Android devices using JavaScript

    How to get Geo location of an iOS and Android devices using JavaScript Generally ,whenever  web developer  developing  an mobile website, then most of times they need  to fetch current location of device(ipod,ipad,android). That time we use  JavaScript  to  fetch current location.Which most  used full. navigator.geolocation.getCurrentPosition(foundnearLocation, noLocation); function foundnearLocation(currentposition) { var lat = currentposition.coords.latitude; var long = currentposition.coords.longitude; alert('Found location: ' + lat + ', ' + long); } function noLocation() { alert('Could not find location'); }  

  • Magento

    Programmatically create invoice of an order in magento

    Programmatically create invoice of an order in magento and create partial invoice of an order For some time need to create invoice of  an order.I have write code for  how to create invoice of an order pragmatically here. First of   load an order by order id/order increment id, Check which items of  that order are available for create invoice. if ,invoice is not created then create invoice of those items #this code is suite if order does have any invoice $order=Mage::getModel('sales/order')->load($orderID); #checkout order capable to create invoice if($order->canInvoice() and $order->getIncrementId()) { $items = array(); foreach ($order->getAllItems() as $item) { $items[$item->getId()] = $item->getQtyOrdered(); } $invoiceId=Mage::getModel('sales/order_invoice_api')->create($order->getIncrementId(),$items,null,false,true); #capture the invoice Mage::getModel('sales/order_invoice_api')->capture($invoiceId);    …

  • Magento

    Magento custom collection filter and sort

    Magento custom collection filter and sort   We have already know how to filter magento product ,customer,wishlist,order  collection  fields filters. But whenever we are working on  non-exiting model collection, then we facing problem.Here i have put some tricks how you can filter a custom collection by a field.In post,i have working on a writing how a custom collection is filter by a filed and how the collection will filter. Suppose a custom collection is #Mage::getModel('[ModulePrefix/Entities]')->getCollection(); $collection=Mage::getModel('[custommodule/customemodule]')->getCollection(); For add addFieldToSelect('*') at that Collection for retrieves all field value for a module is Then want to filter that collection by a field name ‘age’ then use $collection->addFieldToSelect('age'); For add for sort by a…