-
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>…
-
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 Custom Email with html email template
magento Custom Email with html email template Last week ,i was working on magento custom email template where i have create a html template and send mail using Mage::getModel('core/email_template_mailer'); For implement Magento Custom Email with html template. Please follow the below steps: step1:first define html template at your config.xml using below code: <template> <email> <vendor_create_account_email_template translate="label" module="vendor"> <label>New account</label> <file>vendor_account_new.html</file> <type>html</type> </vendor_create_account_email_template> </email> </template> Here vendor_create_account_email_template is always unique id of html template and vendor_account_new.html is html file for custom mail which located at app/locale/Your_store_Language/template/email Step2: Now we will run the email template using below code $storeId=Mage::app()->getStore()->getId(); $Vendor=Mage::getModel('vendor/vendor')->load(57); /** @var $mailer Mage_Core_Model_Email_Template_Mailer */ $mailer = Mage::getModel('core/email_template_mailer'); $emailInfo = Mage::getModel('core/email_info');…
-
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 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…