0

I have different languages on my magento site (different stores) and when I switch language I'm getting parameters in the url (on the start page, it's okey on the sub domains)

So I'm getting this:

?___store=default&___from_store=english

I have tried to edit in

app / code / local / Mage / Core / Store.php

And

languages.phtml

But I can't get it to work...

Johan
  • 33
  • 2
  • 10

2 Answers2

0

you need to set "Add Store Code to Urls" to Yes from URL Option at System->Configuration->Web.Also set "Use Web Server Rewrites" to YES.

Then replace all the code from /template/page/switch/languages.phtml with the code below:

<?php if(count($this->getStores())>1): ?>
<?php
$stores = array();
$_current = null;
foreach ($this->getStores() as $_lang) {
$_selected = $_selected_option = '';
if ( ($_lang->getId() == $this->getCurrentStoreId()) ) {
    $_current =  $_lang;
}
}
?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>

    <?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
    <option value="<?php echo $_lang->getCurrentUrl(false); ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>

it will show the urls like this : http://yourdomain.com/en OR http://yourdomain.com/fr (whatever the store view code you mentioned)

0

I solved it in

app / code / local / Mage / Core / Model / Store.php

In function getCurrentUrl()

On line 1160

return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host']. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') 
. $storeParsedUrl['path'] . $requestString . ($storeParsedQuery ? '?'.http_build_query($storeParsedQuery, '', '&') : '');

Change to

return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path'] . $requestString;
Johan
  • 33
  • 2
  • 10