Magento: Delete Orders Programmatically

Here is a quick code to delete orders programmatically in Magento. In Magento, there isn’t the facility to delete orders from admin grid. You need to write custom code to delete orders in Magento. Here is the full code to do so. This code can be saved in a new file in your Magento root … Read more

Quick Order – Add to Cart by SKU: Magento Extension [FREE]

Quick Order – Add to Cart by SKU is a FREE Magento Extension that allows customers to directly add products to shopping cart using product SKU. This module is compatible with Magento version 1.5 and later (Magento 1.5, 1.6, 1.7, 1.8, 1.9). A Quick Order block will be displayed in left and right sidebar. This … Read more

Magento: Orders made using Paypal are not dispalyed in Customer’s ‘My Orders’ section

Problem: I placed an order in Magento using Paypal payment method. Everything went fine. I was able to pay through Paypal. However, when I login to the shop as a customer, I see that ‘My Orders‘ section is empty. I could not find information of the order I recently placed. Cause: Your order status might … Read more

Magento: Get Sales Quote & Order in both Frontend and Admin

Here is a code snippet to get sales quote and order data in both admin and frontend in Magento. Get Sales Quote in Frontend Mage::getSingleton('checkout/session')->getQuote(); Get Sales Quote in Admin $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote(); Get Latest Order in Frontend $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderId); Get Latest Order in Admin $order = Mage::getModel('sales/order')->getCollection() ->setOrder('created_at','DESC') ->setPageSize(1) ->setCurPage(1) … Read more

Magento: Paypal Express Checkout Showing Empty Order Data [FIXED]

I am using Magento verion 1.4.0.1 and I had this issue. I had enabled Paypal Express Checkout payment method. When I choose this method on checkout, I was redirected to Paypal website but order data was not displayed there. The main reason in my case was due to applied discount to the cart. I had … Read more

Magento: Set Random Order in Collection using RAND()

Scenario: You have created a custom module. You have entered certain data in your database. You need to show the data randomly. Solution: In MySQL the rand() function helps the select query to fetch data randomly. In Magento, you can select random rows from MySQL table using Zend_Db_Expr(‘RAND()’). You have to create a new function … Read more

Magento: Quick way to create order invoice programmatically

Here is a quick and easy way to create order invoice programmatically. Suppose, $_order contains your order. Here goes the code to create invoice:- if($_order->canInvoice()) { /** * Create invoice * The invoice will be in 'Pending' state */ $invoiceId = Mage::getModel('sales/order_invoice_api') ->create($_order->getIncrementId(), array()); $invoice = Mage::getModel('sales/order_invoice') ->loadByIncrementId($invoiceId); /** * Pay invoice * i.e. the … Read more