Drupal to Magento integration, simple link tweak with multilingual site

Featured Image

I see my coworker and friend Željko Prša made a nice little post on Adding a new language in Magento so I figure I’ll jump with a little Drupal to Magento integration trick concerning link issues and multilingual sites. Here is a piece of code you can use in your Drupal templates to do the proper switching from Drupal site to Magento while keeping the selected language of site. Note, this tweak assumes you have the desired language setup on both Drupal and Magento side.

This part goes to some of your Drupal theme file

...
global $language ;
$lname = ($language->language == null) ? 'en' : $language->language; /* like "en", "de" */
$storeView = null;
if($lname == 'de') { $storeView = '?___store=german&___from_store=english'; }
??>
 
</p><p style="text-align: left;"><a id="main_menu_shop" href="<?php echo 'http://'.$_SERVER['HTTP_HOST'].base_path() ?>shop/index.php/someProductLink.html< ?php echo $storeView ?>">Shop</a>
...

Note the $storeView variable; GET ___store holds the value of code name of the view you assigned in Magento, while GET ___from_store variable is used as helper to Magento inner workings. You can basically omit the other one. Your links to Shop from Drupal to Magento should now activate the proper language, the same one you have active on Drupal side.


6 comments

  1. Nice tips. I have a question. Is it possible to mix Drupal and Magento in one web site? I want to show my CMS part in Drupal but the store part in Magento.

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.