• Magento 2

    Magento2 get cart and checkout link in block or phtml

    Magento2 get cart and checkout link in block or phtml In Magento2 get cart and checkout link in block or phtml then you need to call getUrl() method.It is every easy to get those url at Phtml or block class. Also, there is no need to write layout xml code for getting cart and checkout page url at magento 2. If want to get cart & checkout link at PHTML file then try below code: Checkout Url <?php echo $block->getUrl('checkout', ['_secure' => true]);?> Cart Url <?php echo $block->getUrl('checkout/cart', ['_secure' => true]);?>   If you want to call at block class try with Checkout link: $this->getUrl('checkout', ['_secure' => true]);   and…

  • Magento

    How to override a controller in Magento

    How to override a controller in Magento In several time ,we need to override a controlller.How to override a controller in Magento. There are two process available: 1.Basic Old process. 2.Upgrade Process from Magento CE 1.5.0. First have describe second process. It available from Magento CE 1.5.0.Where, i have Overriding controllers magento core controller .I have using before tag for use to override controller of a module-   Here ,step to override a controllers: a)First check which module ,i want to override. Ex1: Suppose have override magento Magento Core Module Mage_Contacts and want override IndexController.php Write below code <frontend> <routers> <contacts> <args> <modules> <customcontacts before="Mage_Contacts">Amit_Customcontacts</customcontacts> </modules> </args> </contacts> </routers> </frontend>…

  • Magento

    Programmatically create Shipment of a new order in magento

    Programmatically create Shipment of a new order in magento Programmatically create Shipment of a new order in magento For some time need to create Shipment of an order.I have write code for how to create Shipment of an order pragmatically here First of all load an order by order id, Check all item of an order are already creating Shipment. if ,invoice is not created then create Shipment of all items Step1 ::load order by order id $order=Mage::getModel(‘sales/order’)->load($orderId); Or $order = Mage::getModel(‘sales/order’)->loadByIncrementId($orderIncrementId); Step2: check a item is available for shipment and set quantity for shipment $qty=array(); $Itemqty = $eachOrderItem->getQtyOrdered() – $eachOrderItem->getQtyShipped() – $eachOrderItem->getQtyRefunded() – $eachOrderItem->getQtyCanceled(); $qty[$eachOrderItem->getId()]=$Itemqty; Step3:create a shipment and…

  • 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'); }