• Magento - Sales Orders Grid - Display Today's Orders Only

    Posted on December 22, 2012 by Nimrod Techn

    Typically, when a Magento store reaches 20,000 orders and more than 5 people load the sales-orders grid concurrently, our online store becomes extremely slow.

     

    How do we solve it? simple. limiting the amount of orders presented in the orders grid for the last 24 hours, unless requested otherwise.

    Copy the app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php file to:

    app/code/local/Mage/Adminhtml/Block/Sales/Order/Grid.php

    Edit the following function, copy-paste from here:

    protected function _prepareCollection()    {

    $collection = Mage::getResourceModel($this->_getCollectionClass());

    ######################## FILTER BY LAST DAY ######################
    $now = Mage::getModel('core/date')->timestamp(time());
    $filter   = $this->getParam($this->getVarNameFilter(), null); //important - check for other requested grid-filters before filtering today's orders

    $dateStart = date('Y-m-d' . ' 00:00:00', $now);
    $dateEnd = date('Y-m-d' . ' 23:59:59', $now);
    $postData = Mage::app()->getRequest()->getPost();
    if (empty($filter)) {
    $collection->addFieldToFilter('`main_table`.created_at', array('from' => $dateStart, 'to' => $dateEnd));
    }
    ##################################################################

     

    $collection->getSelect()->group('entity_id');
    $this->setCollection($collection);

    return $this;

    }


    This post was posted in Speeding Up your Magento Website

  • Changing the admin panel address in Magento

    Posted on October 13, 2012 by Nimrod Techn

    For security reasons, we would prefer changing the admin panel address once we're done developing our Magento store.

    Why? it's better not to let potential hackers know that we're using Magento (exploits, common vulnerabilities) and prevent Brute-force attacks on our admin panel.

    The best of practices would be to place the admin panel on a private, password-protected server and SSL on the admin panel (thus, the password will also be encrypted when we login from unsecured places - let's say a coffee shop).

    Anyway, changing the admin panel address is very easy in Magento.

    Go to app/etc/local.xml

    You will see the following code:

        <admin>
            <routers>
                <adminhtml>
                    <args>
                        <frontName><![CDATA[admin]]></frontName>
                    </args>
                </adminhtml>
            </routers>
        </admin>

    The following line defines the admin panel entrance point (http://your-website.com/admin):

    <frontName><![CDATA[admin]]></frontName>

    Now you can just change "admin" to whatever entrance point you'd like.

    <frontName><![CDATA[example]]></frontName>

    Would change your admin panel address to http://your-website.com/example


    This post was posted in Core

  • Deleting Orders in Magento

    Posted on October 13, 2012 by Nimrod Techn

    Usually there's no need to remove orders in Magento. legally-speaking, it is also not recommended.

    However, sometimes we would like to delete test orders, especially in the very early stages of the website development.

    After Googling for awhile, I found out that some people recommend using the following method in order to delete orders from Magento:

    Mage::getModel('sales/order')->loadByIncrementId($id)->delete();

     

    However, this is far from being the best of practices, and is by no means a proper solution. the order will still be displayed in the order grid (admin panel), just everytime you try to view to order details you will get the following error:
    "This order no longer exists"

    That's because there are still references to the order in other DB tables.

    The related entity ID's have to be removed from the following tables:

    log_quote
    sales_flat_order
    sales_flat_order_address
    sales_flat_order_item
    sales_flat_order_payment
    sales_flat_order_status_history
    sales_flat_order_grid
    sales_flat_invoice_comment
    sales_flat_invoice_item
    sales_flat_invoice
    sales_flat_invoice_grid
    sales_flat_quote_address_item
    sales_flat_quote_item_option
    sales_flat_quote
    sales_flat_quote_address
    sales_flat_quote_item
    sales_flat_quote_payment
    sales_flat_creditmemo_comment
    sales_flat_creditmemo_item
    sales_flat_creditmemo
    sales_flat_creditmemo_grid
    sales_flat_shipment_comment
    sales_flat_shipment_item
    sales_flat_shipment_track
    sales_flat_shipment
    sales_flat_shipment_grid

    Soon enough I will release an extension that removes the orders automatically and will spare you the manual work.


    This post was posted in Core

Items 7 to 9 of 22 total

Page:
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. ...
  7. 8
Magento is a well-engineered eCommerce platform designed to help engineers develop customized eCommerce online stores. Due to lack of proper coding documentation, Engineer-ing.com was created with the sole purpose of instructing Magento developers to-be with the "how-to-do" know-how. In the event of unresolved issues, you are more than welcome to contact me for consultation. However, please do so only if you possess a Software Engineering background and you're able to specify your question.