Product Url not translated completely

  • Posts: 251
  • Thank you received: 2
12 years 1 month ago #44669

Hi,

If I switch between Italian/English versions of my website, the product url of some items changes regulary but in other cases the url don't change completely.

Here an example:

Italian URL
www.hidesign.it/it/catalogo/product/show...-3344/poltrona-sacco

English URL
www.hidesign.it/en/catalogue/product/sho...3344/sacco-armachair

The URL I get switching from Italian to English is
www.hidesign.it/ en/catalogue/product/show/cid-3344/poltrona-sacco

This problem generate duplicated contents. :/

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13102
  • MODERATOR
12 years 1 month ago #44798

I don't see a solution for that.
That's normal actually: The language switcher of Joomla when activated will redirect to the same page and just change the language tag in the URL. So it's normal that the product name in the URL is still the same.

Please Log in or Create an account to join the conversation.

  • Posts: 251
  • Thank you received: 2
12 years 1 month ago #44813

I'm sorry but for me that is not normal...
In fact in some case the URL change in other case not...

That cause much problems of duplicated contents. This is not normal at all!!!

Please Log in or Create an account to join the conversation.

  • Posts: 251
  • Thank you received: 2
12 years 1 month ago #44894

What is the file that generate the URL?

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13102
  • MODERATOR
12 years 1 month ago #45099

The basic URL is generated in the file components/com_hikashop/views/product/view.html.php
However, the redirection for the language change is done in the joomla language module: modules/mod_languages/helper.php
When I say that it's normal that it acts like that, I mean that it's just the way it's done in the language module of Joomla. I don't mean to say that it's the way it should be.

Last edit: 12 years 1 month ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 69
  • Thank you received: 11
11 years 4 months ago #85342

Hi,

I was having the same problem. The Falang Module was only translating the /es /en part of the URL, leaving the rest in english / spanish, depending on what language I was using when viewing a product.

e.g.

madecostarica.com/en/shop/p/141-handbag-with-clasp-closure

madecostarica.com/es/catalogo/p/141-handbag-with-clasp-closure

I managed to get the correct URL by modifying the Falang Module, when translating from Spanish to English but, when I attempt to translate from English to Spanish, I can't get the correct product Name in SPANISH.

I use the HS helper to bring the product name in Spanish but, it seems it return the english produyct name, based on the language I'm using.

In the DB, the spanish name is in the hikashop_product table, while the englishg translation is in the falang_content table.

When I navigate in Spanish, it works because I get the english name from teh falang table and the spanish name from the HS table, but when I switch to english, HS brings the english name only.

How can I get the Spanish name using the HS Helper when navigating in English?

Thanks in advanced.


Eduardo Chongkan - Likan Development
http://likandevelopment.com

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13102
  • MODERATOR
11 years 4 months ago #85570

You can't use the HikaShop class for that because the query that is done by HikaShop is automatically converted by Falang so that you get the name in the current language.

You will have to do the query yourself:
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__hikashop_product WHERE product_id='.$product_id);
$product = $db->loadObject('stdClass', true,'es-ES');
echo $product->product_name;

Please Log in or Create an account to join the conversation.

  • Posts: 69
  • Thank you received: 11
11 years 3 months ago #86850

nicolas wrote: You can't use the HikaShop class for that because the query that is done by HikaShop is automatically converted by Falang so that you get the name in the current language.

You will have to do the query yourself:
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__hikashop_product WHERE product_id='.$product_id);
$product = $db->loadObject('stdClass', true,'es-ES');
echo $product->product_name;



Thanks, just a question, What is the es-ES param for?

BTW, I'm attaching my modified falang helper (modules/mod_falang/helper.php) in case someone wants to take a look into it.

The plugin it uses for getting the correct item IDs depending on the language is mentioned here:

www.hikashop.com/en/forum/3-bug-report/7...ilanguage.html#86849

You can see the URL translations working here (On products): madecostarica.com/


Eduardo Chongkan - Likan Development
http://likandevelopment.com
Last edit: 11 years 3 months ago by likandev. Reason: Removed attachment and added a corrected version in another post.

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
11 years 3 months ago #86913

Hi there,

The es-ES parameter is for the language (spanish there).
Thanks for the file ;)

Please Log in or Create an account to join the conversation.

  • Posts: 69
  • Thank you received: 11
11 years 3 months ago #87030

Thanks Eliot,

I know it is the international language code for Spanish-Spain, my question was, why did you send it as a parameter to the loadObject Method?

I see the method only asks for 1 parameter:

public function loadObject($class = 'stdClass')

Also, today I tested and the site was broken. I was sure I tested it last night and it worked, maybe some sort of cache..

I traced it down, and it seems the problem was in fact the extra parameters of the loadObject method, I checked the library method and I foudn what I put above, so I removed the parameters and used it as I normally use it. Joomla 2.5, not sure if 3.0 implements your method.

I'm curretnly using:
                $db = JFactory::getDBO();
                $db->setQuery('SELECT * FROM #__hikashop_product WHERE product_id='.$vars['cid']);
		$product = $db->loadObject();
	        $lkname = $product -> product_name;

I also noticed that, if there was no translation available for a product in Falang, it would return an empty name. So I changed the helper file to use the default product name when no translation was found in Falang


Eduardo Chongkan - Likan Development
http://likandevelopment.com
Attachments:
Last edit: 11 years 3 months ago by likandev.

Please Log in or Create an account to join the conversation.

  • Posts: 81677
  • Thank you received: 13102
  • MODERATOR
11 years 3 months ago #87256

Hi,

The falang plugin overrides the database driver of joomla and all its database functions with its owns.
And it adds additional parameters to the functions.
One of the parameter is the language code, so that you can force it to load the data in a certain language.
See the code from the file plugins/system/falangdriver/falangdriver.php :

	function loadObject( $class = 'stdClass', $translate=true, $language=null ) {
		$objects = $this->loadObjectList("",$class,$translate,$language);
		if (!is_null($objects) && count($objects)>0){
			return $objects[0];
		}
		return null;
	}

The following user(s) said Thank You: likandev

Please Log in or Create an account to join the conversation.

Time to create page: 0.096 seconds
Powered by Kunena Forum