Core

Magento Core Development Tips and Tricks

  • 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

  • Setting up the web configuration on local.xml instead of DB in Magento

    Posted on October 13, 2012 by Nimrod Techn

    First of all, why? why setting up the web configuration on the local.xml, when Magento's default setting is DB?

    We would prefer to set up the web configuration on the local.xml, in case we use CDN / several servers that use the same DB.

    In that case, only 1 address (let it be js/css or base url) is configured, when we actually need 2-3 or more.

     

    The solution would be, to have the addresses on the local.xml of each one of the server  instances.

    How do we set this up?

    Go to app/etc/local.xml and add the following lines:

     <stores>
           <STORECODE1>
    		<web>
    			<unsecure>
    				<base_url>http://www.your-server-instance.com/</base_url>
    				<base_web_url>{{unsecure_base_url}}</base_web_url>
    				<base_link_url>{{unsecure_base_url}}</base_link_url>
    		       </unsecure>
    			<secure>
    				<base_url>https://www.your-server-instance.com/</base_url>
    				<base_web_url>{{secure_base_url}}</base_web_url>
    				<base_link_url>{{secure_base_url}}</base_link_url>
    		       </secure>
    	       </web>
            </STORECODE1>
           <STORECODE2>
    		<web>
    			<unsecure>
    				<base_url>http://www.your-server-instance.com/</base_url>
    				<base_web_url>{{unsecure_base_url}}</base_web_url>
    				<base_link_url>{{unsecure_base_url}}</base_link_url>
    		       </unsecure>
    			<secure>
    				<base_url>https://www.your-server-instance.com/</base_url>
    				<base_web_url>{{secure_base_url}}</base_web_url>
    				<base_link_url>{{secure_base_url}}</base_link_url>
    		       </secure>
    	       </web>
            </STORECODE2>
       </stores>
        <default>
            <web>
                <unsecure>
                    <base_url>http://www.your-server-instance.com/</base_url>
                    <base_web_url>{{unsecure_base_url}}</base_web_url>
                    <base_link_url>{{unsecure_base_url}}</base_link_url>
                    <base_js_url>{{unsecure_base_url}}js/</base_js_url>
                    <base_skin_url>{{unsecure_base_url}}skin/</base_skin_url>
                    <base_media_url>{{unsecure_base_url}}media/</base_media_url>
                </unsecure>
                <secure>
                    <base_url>https://www.your-server-instance.com/</base_url>
                    <base_web_url>{{secure_base_url}}</base_web_url>
                    <base_link_url>{{secure_base_url}}</base_link_url>
                    <base_js_url>{{secure_base_url}}js/</base_js_url>
                    <base_skin_url>{{secure_base_url}}skin/</base_skin_url>
                    <base_media_url>{{secure_base_url}}media/</base_media_url>
                </secure>
            </web>
        </default>
    </config>

    Replace STORECODE1 / STORECODE2 with the actual store codes you use.
    Replace  http://www.your-server-instance.com/ with your URL addresses.

    Second step, you have to remove from the DB table core_config_data everything that begins with web/secure AND web/unsecure.
    If you don't, Magento will continue taking our addresses from the DB (as always, the DB is the "strongest"). Remove the cache, and try to start your application.

     

    Bear in mind, the <stores> section isn't mandatory - if you have just one instance and wish to start the default website, you can copy only that section and everything will work out just fine.


    This post was posted in Core

Items 1 to 3 of 4 total

Page:
  1. 1
  2. 2
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.