Wednesday, June 29

How to Create Shipping Labels in Magento

Hi here i will show the detailed steps to create shipping labels for magento orders

Step 1:
Open the file:
app/design/adminhtml/default/default/template/sales/order/view/info.phtml

Around line 170, after
<h4><?php echo Mage::helper(‘sales’)->__(‘Shipping Address’) ?></h4>
       

put the following code:
Landscape
Portrait
Print Label:

Step 2:
Place at the bottom of the file, the following code:
<script type="text/javascript">
<?php
$shipaddr= trim($_order->getShippingAddress()->getFormated(true));
$splitx=explode("\n",$shipaddr);
$end = "";

$end = Mage::getBaseUrl();
    echo "\n".'var end="'.$end.'"; '."\n" ;
    echo"\n".'var shipx="'.urlencode($shipaddr).'"; '."\n" ;
?>

var popUpWin;

function labelPrintLandscape() {
   var url=end.replace("index.php/admin/","").replace("index.php/","");
   url=url +"custom/print_label_landscape.php?addr="+shipx;
   popUpWin = open(url,'popUpWin','toolbar=yes,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width=500,height=300,left=100,top=100,screenX=100,screenY=100');
}

function labelPrintPortrait() {
    var url=end.replace("index.php/admin/","").replace("index.php/","");
    url=url +"custom/print_label_portrait.php?addr="+shipx;
    popUpWin = open(url,'popUpWin','toolbar=yes,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes, width=500,height=300,left=100,top=100,screenX=100,screenY=100');
}
</script>

Step:3
Create the directories /custom and /custom/dompdf on the site root folder.
Download the dompdf library here and extract its contents to /custom/dompdf.

Step:4
Create the file /custom/print_label_portrait.php and with the following content:

<?php
$html ='<html<head></head><body>';

$url = str_replace("addr=","",$_SERVER["QUERY_STRING"]);
$decoded_url = urldecode($url);

//REMOVE PHONE NUMBER
//$decoded_url = explode("T:",$decoded_url); $decoded_url = $decoded_url[0];

$html = utf8_decode(str_replace("T:","",urldecode($decoded_url)));

$html.="</body></html>";

require_once("dompdf/dompdf_config.inc.php");

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$paper = array(0,0,152.82,285.83);
$dompdf->set_paper($paper , 'portrait');
$dompdf->render();
$dompdf->stream("label_landscape.pdf");
?>


Step:5
Create the file /custom/print_label_landscape.php and with the following content:
<?php
$html ='<html<head></head><body>';

$url = str_replace("addr=","",$_SERVER["QUERY_STRING"]);
$decoded_url = urldecode($url);

//REMOVE PHONE NUMBER
//$decoded_url = explode("T:",$decoded_url); $decoded_url = $decoded_url[0];

$html = utf8_decode(str_replace("T:","
",urldecode($decoded_url)));

$html.="</body></html>";

require_once("dompdf/dompdf_config.inc.php");

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$paper = array(0,0,152.82,285.83);
$dompdf->set_paper($paper , 'landscape');
$dompdf->render();
$dompdf->stream("label_landscape.pdf");
?>


Now everything finished. In the administration page, go to a order page and you should see two links in the address box header, clicking in one of the should generate the label.

hope it Helps.Thanks...

Thursday, June 23

Change default logo in Magento Invoice printout

Magento allows you to change the default logo and address used on HTML & PDF invoice printouts. Granted, it is very restricted but here is how you do it:

1. In your Admin Console. Go to Configuration -> Sales -> Sales -> Invoice and Packing Slip Design  

2. It’s all very self explanatory. However, be aware that your logo has to be 200px x 50px

    Hope it helps.. Thanks

    Friday, June 17

    How to Enable Email to Friend Option for Guest Users in Magento

    when I do Magento sites for my customers, they want to show a button, EMAIL TO A FRIEND or SEND TO A FRIEND on the product details page. Magento doesnt show you that, until and unless you are logged in.
    So here is a small trick to get it :
    Goto System > Configuration > Email to a Friend.
    Enable it for GUESTS.
    Refresh your cache from System > Cache management and then open any of your product.
    You will see a new link, EMAIL TO A FRIEND.
    Normally, the link will look like this,
    http://www.example.com/sendfriend/product/send/id/174/
    SO, just copy that link and use it for your product details page customization or any other purpose also.
    Product Details page are controlled from this file ,
    /public_html/app/design/frontend/default/your-theme/template/catalog/product/view.phtml

    Hope it Helps .. thanks ...

    Saturday, June 11

    Magento Community Modules


    1.   1. Magento German Language Pack  
     Name :  Locale_Mage_community_de_DE
                Version 1.0 : magento-community/Locale_Mage_community_de_DE

    2.   2. Magento French (France) Language Pack
    Name:  Magento Community Modules - French (France) Language Pack
                Version 1.0: magento-community/Locale_Mage_community_fr_FR

    3.   3. Blog
    Name : Blog - Community Edition
    The Blog extension gives you a noteworthy opportunity to communicate with your regular customers and casual visitors. With Blog you can create an interactive two-way communication platform to provide official information on your store news, upcoming products, promotions, and get customers’ feedback.
                Version 2.0 : http://connect20.magentocommerce.com/community/AW_Blog
                Version 1.0 : magento-community/AW_Blog

    4.   4. Enahanced Admin Product Grid
    Name : Enhanced Admin Product Grid
    Adds some useful, customizable features to the admin product management grid including new columns and tools.
    Version 2.0 :  http://connect20.magentocommerce.com/community/TBT_Enhancedgrid
    Version 1.0 : magento-community/TBT_Enhancedgrid
     
    5.   5. Bank Payment
    Name :  BankPayment
    The module allows you to enter one or more bank accounts in the payment configuration which are displayed to the customer during the checkout and the order email to notify him where to transfer the money.
    Version 2.0 :  http://connect20.magentocommerce.com/community/BankPayment
    Version 1.0 : magento-community/BankPayment
     
    6.   6. Magento Light Box
    Name :  Magento Easy Lightbox
    This small extension will help to install Lightbox widget. Installation and configuration will take approximately 5 minutes. No files are replaced and no codding experience needed to install! Magento EasyLightbox Extension
    Version 2.0 :  http://connect20.magentocommerce.com/community/magento_easy_lightbox
    Version 1.0 :  magento-community/magento_easy_lightbox
     
    7.   7. Fooman Speedster
    Name :  Fooman Speedster
    Speed up your store by combining, compressing and caching JS and CSS.
    Version 2.0http://connect20.magentocommerce.com/community/Fooman_Speedster
    Version 1.0 : magento-community/Fooman_Speedster
     
    8.   8. Market Ready Germany
    Name :  Market Ready Germany
    This extension package provides all necessary modules (18) to preconfigure Magento for the German b2c market
    Version 2.0http://connect20.magentocommerce.com/community/market_ready_germany
    Version 1.0 : magento-community/market_ready_germany
     
    9.   9. Vertical Navigation
    Name :  Vertical Navigation with CSS Classes
    Vertical Category Navigation with subcategories and fine css classes - NEW: You can now setup whether VertNav should show EVERYTHING (nice for jQuery) or ..just a few levels in the category tree.
    Version 2.0http://connect20.magentocommerce.com/community/RicoNeitzel_VertNav
    Version 1.0 :  magento-community/RicoNeitzel_VertNav
     
    1110    Cash On Delivery
    Name :  CashOnDelivery
    Cash on Delivery allows to book additional fee on delivery depending on inland or international delivery.
    Version 2.0http://connect20.magentocommerce.com/community/CashOnDelivery
    Version 1.0 :  magento-community/CashOnDelivery
     
    1111. Gift Certificates
    Name :  Unirgy_Giftcert
    Allow your customers to purchase and use Gift Certificates.
    Version 2.0http://connect20.magentocommerce.com/community/Unirgy_Giftcert
    Version 1.0 :  magento-community/Unirgy_Giftcert
     
    1112. Light Box
    Name :  IG LightBox
    This extension will install a wonderful and ready-to-use LightBox widget in your Magento store.
    Version 2.0http://connect20.magentocommerce.com/community/IG_LightBox
    Version 1.0 :  magento-community/IG_LightBox
     
    1 13.  Dutch Language Pack (Netherlands)
    Name :  Magento Community Modules - Dutch (Netherlands) Language Pack
    Version 2.0http://connect20.magentocommerce.com/community/Locale_Mage_community_nl_NL
    Version 1.0 :  magento-community/Locale_Mage_community_nl_NL
     
     114.  Payone Extension
    Name :  PAYONE Extension
    PAYONE FinanceGate payment gateway for all german online and offline payment methods including PayPal, all major Credit Cards and Maestro.
    Version 2.0http://connect20.magentocommerce.com/community/Mage_Payone
    Version 1.0 :  magento-community/Mage_Payone
     
    1 15.    Multiple Table Rates
    Name :  WebShopApps MatrixRate - #1 Multiple Table Rates Extension CERTIFIED BUG FREE
    The Original & much copied Multiple Tablerates using a CSV file, with a wealth of features
    Version 2.0http://connect20.magentocommerce.com/community/Auctionmaid_Matrxrate
    Version 1.0 :  magento-community/Auctionmaid_Matrxrate
     
     116. Easy Tabs
    Name :  Magento EasyTabs
    This small extension will help to add informational tabs on product page
    Version 2.0http://connect20.magentocommerce.com/community/magento_easy_tabs
    Version 1.0 :  magento-community/magento_easy_tabs
     
       17. Live Chat
    Name :  MagentoLiveChat
    A Live Chat in Magento allow your visitors to dialog with your operators
    Version 2.0 http://connect20.magentocommerce.com/community/Beck_LiveChat
    Version 1.0 :  magento-community/Beck_LiveChat


    18 18. Cash Ticket Symmetrics
    Name :  Cash-Ticket Symmetrics
    Version 2.0 http://connect20.magentocommerce.com/community/symmetrics_cashticket
    Version 1.0 :  magento-community/symmetrics_cashticket
      
    1  19. Banner Slider
    Name :  Banner Slider
     Add ability to show a slider of image on home page
    Version 2.0 http://connect20.magentocommerce.com/community/Magestore_BannerSlider
    Version 1.0 :  magento-community/Magestore_BannerSlider



         20. Best Seller / Top Seller
    Name :  Bestsellers module
     Magento Bestsellers module automatically generates the list of your online store's best selling products and displays it at the home page (or some other page) in the customer area.
    Version 2.0 http://connect20.magentocommerce.com/community/Beck_LiveChat
    Version 1.0 :  magento-community/Beck_LiveChat
     
     
         21. Social Bookmarking
    Name :  Magento Social Bookmarking Services
    Share your products, categories, CMS pages... to Social Bookmarking Services (Twitter, Digg, Facebook, MySpace...) This extension adds a block / Widget allowing the distribution of your pages to Social Bookmarking services of your choice
    Version 2.0 http://connect20.magentocommerce.com/community/Magentix_SocialBookmarking
    Version 1.0 :  magento-community/Magentix_SocialBookmarking
     
    22 22. Maintainance Page
    Name :  Maintenance Page - ArtsOn.IT
    The Maintenace page for Magento Stores.
    Version 2.0 http://connect20.magentocommerce.com/community/ArtsOnIT_OfflineMaintenance
    Version 1.0 :  magento-community/ArtsOnIT_OfflineMaintenance
     
         23. Resize Image
    Name :  Direct Resize
    Give the possibility to resize images without distorted them. You can specify a Width and a Height value as well as a ratio.
    Version 2.0 http://connect20.magentocommerce.com/community/NetAmbition_DirectResize
    Version 1.0 :  magento-community/NetAmbition_DirectResize
    24 24. Spanish Language (Spain) Pack
    Name :  Magento Community Modules - Spanish (Spain) Language Pack
    Version 2.0 http://connect20.magentocommerce.com/community/Locale_Mage_community_es_ES
    Version 1.0 :  magento-community/Locale_Mage_community_es_ES
     
    25 25. JQuery Base
    Name :  Mxperts - jQuery Base
    Version 2.0 http://connect20.magentocommerce.com/community/Mxperts_Jquery
    Version 1.0 :  magento-community/Mxperts_Jquery
     
         26. Canonical URL
    Name :  Canonical URL for Magento
    This extension adds the new canonical links to the head of your Magento pages, for a more in-depth explanation, see Yoast.com. More about Magento SEO in general at Yoast.
    Version 2.0 http://connect20.magentocommerce.com/community/canonical_url
    Version 1.0 :  magento-community/canonical_url
     
         27. Interakting Home Page Slider
    Name :  Interakting slider
    Add a slideshow of CMS content on the page of your choice and custom it for each Store Views
    Version 2.0 http://connect20.magentocommerce.com/community/BusinessDecision_Interaktingslider
    Version 1.0 :  magento-community/BusinessDecision_Interaktingslider
     

     2  28. Featured Products
    Name :  Featured Products
    This extension gives your Magento ability for easy management of featured products. Frontend features include separate interface for listing of all featured products and a block usage for easy placement to the interfaces of your choice.
    Version 2.0 http://connect20.magentocommerce.com/community/Inchoo_FeaturedProducts
    Version 1.0 :  magento-community/Inchoo_FeaturedProducts
     
    29 29. Portuguese Language (Brazil) Pack
    Name :  Magento Community Modules - Portuguese (Brazil) Language Pack
    Version 2.0 http://connect20.magentocommerce.com/community/Locale_Mage_community_pt_BR
    Version 1.0 :  magento-community/Locale_Mage_community_pt_BR
     
    3  30. Change Attribute Set
    Name :  Flagbit Change Attribute Set
    In Magento every product has a fixed attribute set that cannot be changed after the product's creation. This is in many productive contexts not an acceptable limitation. This module overrides the standard behaviour and makes it possible to change attribute sets after the item's creation making Magento even more flexible. :)
    Version 2.0 http://connect20.magentocommerce.com/community/Flagbit_ChangeAttributeSet
    Version 1.0 :  magento-community/Flagbit_ChangeAttributeSet
     
    31 31.Google Analytics Plus
    Name :  Fooman GoogleAnalyticsPlus
    Additional features for the default GoogleAnalytics module
    Version 2.0 http://connect20.magentocommerce.com/community/Fooman_GoogleAnalyticsPlus
    Version 1.0 :  magento-community/Fooman_GoogleAnalyticsPlus
    3  32.SEO Theme
    Name :  Yoast Blank SEO Theme
    This is a clean simplistic SEO optimized Theme based on the core Magento Blank Theme. This theme can be easily customized by professional designers.
    Version 2.0 http://connect20.magentocommerce.com/community/Yoast_Blank_Seo_Theme
    Version 1.0 :  magento-community/Yoast_Blank_Seo_Theme
     
    33 33. Admin Navigaion Bar
    Name :  Navigation Bar administrator
    With this extension you can manage the navigation bar on your site.
    Version 2.0 http://connect20.magentocommerce.com/community/Mage_Navadmin
    Version 1.0 :  magento-community/Mage_Navadmin
    Ref : https://www.magentocommerce.com/

    Thursday, June 9

    How to Show Language Switcher in Magento Header / Footer

    Step 1: Create a new phtml file (template/page/switch/stores-top.phtml) and write the following code in it:

    <?php if(count($this->getGroups())>1): ?>
    <div class="language-switcher" style="margin-left:15px">
        <label for="select-store"><?php echo $this->__('Select Store') ?>: </label>
        <select id="select-store" onchange="location.href=this.value">
        <?php /*foreach ($this->getStores() as $_store): ?>
            <option value="<?php echo $_store->getUrl('') ?>"<?php if($_store->getId()==$this->getCurrentStoreId()): ?> selected="selected"<?php endif; ?>><?php echo $_store->getName() ?></option>
        <?php endforeach;*/ ?>
        <?php foreach ($this->getGroups() as $_group): ?>
            <?php $_selected = ($_group->getId()==$this->getCurrentGroupId()) ? 'selected="selected"' : '' ?>
            <option value="<?php echo $_group->getHomeUrl() ?>" <?php echo $_selected ?>><?php echo $this->htmlEscape($_group->getName()) ?></option>
        <?php endforeach; ?>
        </select>
    </div>
    <?php endif; ?>
    

    Add store_switcher_top block after store_language block inside header block of page.xml present around line #66 :-

    <block type="page/html_header" name="header" as="header">
        <block type="page/template_links" name="top.links" as="topLinks"/>
        <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
        <block type="page/switch" name="store_switcher_top" as="store_switcher_top" template="page/switch/stores-top.phtml"/>
        <block type="core/text_list" name="top.menu" as="topMenu"/>
    </block>
    

    Add getChildHtml(’store_switcher_top’) below getChildHtml(’store_language’) in template/page/html/header.phtml like below :-

    <?php echo $this->getChildHtml('store_language') ?>
    <?php echo $this->getChildHtml('store_switcher_top') ?>
    

    That’s all. Now, you can see store selector.

    Hope it Helps.. Thanks..

    Wednesday, June 8

    How to Use Magento Session with in Wordpress

    My current setup is still the same with the rest of my post here having ‘htdocs’ as my root directory, magento has its own subdirectory ‘htdocs/magento’ as well as wordpress in ‘htdocs/wordpress’. The goal here is to able to use Magento as if it is a native function within our WordPress installation.

    Since there is an existing function collision between Magento and WordPress because both application has an existing translator function named __(), our first task is to automatically detect if the function already exists and disable it in Magento and run as usual if it doesn’t.

    To do that, locate the file below in your Magento installation:
    Copy the file functions.php below from your Magento core folder

    path:to-your-htdocs/magento/app/code/core/Mage/Core/functions.php

    and paste it in the Magento local folder which can be found below and open it for editing (create needed folders if it doesn’t exists):

    path:to-your-htdocs/magento/app/code/local/Mage/Core/functions.php

    Locate the function __() or go to line 93:

    function __()
    {
        return Mage::app()->getTranslator()->translate(func_get_args());
    }
    

    replace it with this:
    if (!function_exists('__')) {
     function __()
     {
      return Mage::app()->getTranslator()->translate(func_get_args());
     }
    }
    
    Why did I choose to disable Magento’s translator function instead of WordPress’? It is because in Magento, it has already been marked as deprecated in version 1.3 and searching throughout the installation I didn’t see any file that uses that function.

    Now that the function collision has been solved, let’s proceed in modifying WordPress to include our Mage.php file. Locate and open the WordPress file below:

    path-to-your-root-htdocs/wordpress/wp-includes/functions.php

    Scroll down to the end of the file. Add the codes below right after the last function statement.

    function magento($name = "frontend") {
     // Include Magento application
     require_once ( "../magento/app/Mage.php" );
     umask(0);
     // Initialize Magento
     Mage::app("default");
     return Mage::getSingleton("core/session", array("name" => $name));
    }
    

    That’s it! I know it’s weird that it isn’t like the solution given by others that require modifying a lot of files. Nevertheless, I tested it and it does work. You just have to make sure that whenever you use the magento() function to any file within WordPress, always place it at the top most part of the code where there’s no header request or else you will get a similar error below:

    Fatal error: Uncaught exception 'Exception' with message 'Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent .....................

    An example of how to use this is to check whether a customer is logged in or not. To do this, open the index.php of WordPress’ default theme which is Twenty Ten 0.7:

    path-to-your-root-htdocs/wordpress/wp-content/themes/twentyten/index.php

    Just below line 15, add the magento() function. It should look like the codes below:

    <?php
    
    
     magento(); 
    
    ?>
    
    <?php get_header(); ?>
    

    Add the code below marked as Magento’s custom greeting right after the get_header() function of WordPress in the same file:

    
    
    
    isLoggedIn()){ $magento_message .= $session->getCustomer()->getData('firstname').' '; $magento_message .= $session->getCustomer()->getData('lastname').'!'; }else{ $magento_message .= "Guest!"; } echo $magento_message; //echo "
    "; //print_r($session); ?>

    The purpose of the code change above is to display a ‘Welcome [customer name here]‘ when a customer is logged in, and show ‘Welcome Guest’ when they are not.

    Hope it Helps.. Thanks...

    How-To Create a 301 Redirect in Magento URL Rewrite Management

    I’ve noticed that I’m getting a lot of traffic recently for search queries regarding my previous post on some fairly unimportant details in the process of creating a 301 Permanent redirect using Magento’s URL Rewrite Management. I thought I would take a step back and post a quick how-to:

    First: Is the redirect you want to implement at the page (“path”) or domain (“hostname”) level? If you need to redirect any part of the domain, you’ll have to do so somewhere else (like in the .htaccess file of your apache server)

    Assuming then that this will be a redirect from one page to another, if I wanted to move and/or rename this page to a new URL, for example:

    From: http://thewhatscool.com/seo/how-to-magento-301-redirect.html

    To: http://thewhatscool.com/seo/magento-redirect-implementation.html

    I would do the following in Magento to create the appropriate pemanent redirect:

    1. Navigate to Catalog > Url Rewrite Management
    2. Click the “Add Urlrewrite” button
    3. Select “Custom” from the “Create Urlrewrite” drop-down menu
    4. The “Urlrewrite Information” form would be completed thusly:

    ID Path: seo/how-to-magento-301-redirect.html
    Request Path: seo/how-to-magento-301-redirect.html
    Target Path: http://thewhatscool.com/seo/magento-redirect-implementation.html
    Redirect: Permanent(301)

    So, to recap:
    ID Path and Request path are the same: the path off the root of the url to redirect FROM – everything after (not including) the domain name and trailing slash.
    Target path is the URL to redirect TO.

    Thanks thewhatscool.com.

    How to remove index.php from magento URL

    Hi, if you are using Magento and your site urls are looking this way,

    http://www.mymagentostore.com/index.php/cloths/men.phtml

    So, you must be looking , how to remove that index.php from the url, as thats not good for Search Engine Indexing at all. So, here is the trick.

    1. Goto your site root folder and you can find the .htaccess file. Just edit that. Open it on a text editor and find this line, #Rewrite Base /magento/ . Just replace it with Rewrite Base / .

    2. Then goto your Admin Panel and enable the Web Server Rewrites. You can find it at System > Configuration > Web > Search Engine Optimization.

    3. Then goto your Cache Management page ( System > Cache Management) and refresh your Cache and also refresh the Web Redirects.

    now check the front end.

    Hope it helps.. Thanks..