Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


magento multilanguage double change in language resuts in 404 or how to chang


magento multilanguage double change in language resuts in 404 or how to chang  using -'url,magento,seo,http-status-code-404,multilingual'

I have a problem with a magento installation. I used Magento ver. 1.5.0.1, community edition to develop this website http://cissmarket.com/.

The problem appears when I change the language from the EU version to French and after that to German. The change to french is ok, but when in the same page i change to German i receive a 404 error. Also this is generation 404 errors in the Google webmaster tools and when i try for example to take this link and paste it in the browser it gives me also a 404 error. I have there some 50 products and ~550 404 errors in Google Webmaster tools. I understand that the problem is from what I described.

Moreover I have a SEO problem since I have this page in french:

http://cissmarket.com/de/cartouches-refilables.html

And when I switch to the german version of the website it takes me to this link

_from_store=fr">http://cissmarket.com/de/cartouches-refilables.html?_from_store=fr (if i try now to switch to uk I will get the 404 mentioned above)

instead of going to this one:

http://cissmarket.com/de/nachfullpatronen.html

Already checked this 404 error when switching between stores when in a category on magento but it does not relate to my problem.

About settings:


I use the caching service and also I did index all the content.
The product or category I am trying to access is available and set active for all the languages.
System > General > Web > URL options > Add Store Code to Urls is set
to yes.
System > General > Web > Search Engines Optimization > Use Web Server
Rewrites is set to yes.
No other changes has been made to the .htaccess file except for the
ones that the system itself made.


So to conclude: the problem is the 404 given by 2 succesive changes of the language and the bad url address when I switch from one page to another.

Any suggestions would be appreciated.

UPDATE: tried this _from_store-query-parameter-when-switching-store-views-in-magento">http://www.activo.com/how-to-avoid-the-_from_store-query-parameter-when-switching-store-views-in-magento but it results in a 404 at the first language change

Edit #1:

Found the problem: file languages.phtml contained this code <?php echo str_replace ("/fr/","/de/",$_lang->getCurrentUrl()); ?> and actually did replace only the language code and not the whole url according to the corresponding translation.

So applied to this


  http://cissmarket.com/fr/cartouches-refilables.html


it will return


  http://cissmarket.com/de/cartouches-refilables.html


So does anyone know how to get the corresponding URL of the current page for the other languages available in the store?

Edit #2 (using @Vinai solution):

It works on the product pages but not on the category yet.
    

asked Oct 23, 2015 by ankitarajoria4
0 votes
15 views



Related Hot Questions



Government Jobs Opening

(Note: you need to do this for all of your translated 404 pages. In each 404 page you need to modify lang="en" for your storeview url value)

Because the wysiwyg (tiny_mce) does not allow javascript to be threated, you'll have to modify js/mage/adminhtml/wysiwyg/tinymce/setup.js. Add the following code under line 97 (under "var settings = "):

extended_valid_elements : 'script[language|type|src]',
answered Oct 23, 2015 by dahiyabecomp
0 votes

For Magento 1.7.0.2 and 1.8.0.0 this is the bugfix:

Starting from line 251 of /app/code/core/Mage/Core/Model/Url/Rewrite.php

:

Mage::app()->getCookie()->set(Mage_Core_Model_Store::COOKIE_NAME, $currentStore->getCode(), true);

// endur 02-03-2013 fix for missed store code

// $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();

if (Mage::getStoreConfig('web/url/use_store') && $storeCode = Mage::app()->getStore()>getCode()) { 
    $targetUrl = $request->getBaseUrl(). '/' . $storeCode . '/' .$this->getRequestPath();
    } else {
      $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();
    }

// endur 02-03-2013 end

Make sure to create a custom copy of the file in: /app/code/local/Mage/Core/Model/Url/Rewrite.php or: /app/code/local/YourTheme/Mage/Core/Model/Url/Rewrite.php

source:

answered Oct 23, 2015 by patilkiran.101
0 votes

It looks like a bug in Magento 1.7. Here is a hack that worked for me. It should work for a two language store with store code in URL

in var/www/html/shop1/app/code/core/Mage/Core/Model/Url/Rewrite.php

remove this line

 // $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();

and add these:

 $storecode = Mage::app()->getStore()->getCode();
 if ($storecode='en')
 {
    $targetUrl = $request->getBaseUrl(). '/'.$storecode.'/' . $this->getRequestPath();
 }
 else
 {
    $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath();
 }
answered Oct 23, 2015 by akasati02
0 votes

Here a another solution for this problem. Just add this code after "$this->load($pathInfo, 'request_path');" in app/code/core/Mage/Core/Model/Url/Rewrite.php:

        if (!$this->getId() && !isset($_GET['___from_store'])) {
            $db = Mage::getSingleton('core/resource')->getConnection('default_read');
            $result = $db->query('select store_id from core_url_rewrite WHERE request_path = "' . $pathInfo . '"');
            if ($result) {
                $storeIds = array();
                if($row = $result->fetch(PDO::FETCH_ASSOC)) {
                    $storeId = $row['store_id'];
                    $storeCode = Mage::app()->getStore($storeId)->getCode();

                    header("HTTP/1.1 301 Moved Permanently");
                    header("Location: http://" . $_SERVER['HTTP_HOST'] . "/" . $pathInfo . "?___store=" . $storeCode);
                    exit();
                }
            }
        }
answered Oct 23, 2015 by sameer rathore
0 votes

guys. For this error there is magento module. It have rewrite 2 models http://www.magentocommerce.com/magento-connect/fix-404-error-in-language-switching.html

answered Oct 23, 2015 by deepak

...