Breadcrumb issue when translating with Falang

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
8 years 8 months ago #250869

-- url of the page with the problem -- : test server
-- HikaShop version -- : 2.6.2
-- Joomla version -- : 3.6.2
-- PHP version -- : 5.6
-- Browser(s) name and version -- : Any

We building a test site with English and Spanish (with Falang) We ran into an issue when scrolling backwards and forwards with products that were in more than one category (irrespective of language selected). So for example we have the following category structure in Hikashop

Company Name -> Product Line 1 -> SubCategory 1
Company Name -> Product Line 1 -> SubCategory 2

We then have menu menu links starting with Product Line 1 then two submenu links to SubCategory 1 and SubCategory 2

We find that if you go to if you have a product that is both Subcategory 1 and Subcategory 2, if you go to Subcategory 1 and then view the single product pages and scroll backwards and forwards when you get the product which is in both categories then instead of scrolling products just in Subcategory 1 you then have products from Subcategory 2 and vice versa.

We found that if we set in the datashop configuration -> SEF url options -> Simplified breadcrumbs to NO, so now the URL now has category_pathway-## the problem was resolved. Scrolling backwards and forwards we just see the products in Subcategory 1, or Subcategory 2 are shown.

However changing Simplified Breadcrumbs to NO created another problem. We have the website with English the base language then translated in Spanish. Viewing the products in English everything show correctly. However if you view the products in Spanish the Breadcrumb show incorrectly.

So if we are view a product in subcategory 1 the breadcrumb in English is:

Home > Product Line 1 > SubCategory 1 -> Product Name

In Spanish it becomes (obviously translated in Spanish)

Home > Product Line 1 > SubCategory 1 > Company Name > Product Line 1 > Subcategory 1 > Product Name

So in the breadcrumb we have the menu structure plus the hikashop cateogry structure.

Setting Simplified Breadcrumbs to YES the breadcrumb structure in Spanish returns to normal

Home > Product Line 1 > SubCategory 1 -> Product Name

but then we have problem again of scrolling backwards and forwards when you get to product in more than one category.

Is there something we can change in the settings to resolve this issue(s)?
Thanks, J

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 8 months ago #250879

Hi,

Without knowing the links you have and how the menu items are configured in your examples, it will be hard to say much.

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

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
8 years 8 months ago #251006

We'll set Simplified Breadcrumbs to YES the NO and look at what data is called scroll through the products in each case and see if we can find a way of setting simplified Breadcrumbs to YES and just viewing products in the same category and the we'll report back, with screenshots and other info as necessary.

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

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
8 years 7 months ago #254955

Hi Nicolas,

I apologise for not replying before but we needed a moment to look at the issue further and we have found a solution to our issues but it required a hack of the source code. We have tested with Hikashop 2.6.4 and Falang 2.7.0 on Joomla 3.6.4.

To recap in our setup we have several products we are assigned to multiple categories. The category views work correctly and the product listings work correctly. The problem was when you viewed a single product and then clicked on the links to scroll though to view other products in the same category. At a certain point it would jump from the current category and begin showing products from a different category.

We kind of solved the problem by going into the configuration in the SEF url section and setting simplified breadcrumbs to "No". It solved the problem in English which is the default language but in other languages the breadcrumb was screwed up. It basically contained repetitions of itself.

So we went back and set simplified breadcrumbs to "Yes" and had a look at the code in com_hikashop/views/product/view.html.php in the frontend and we see in line 1537 this if $category_id is empty it then looks up the category with loadResult() call which just returns a single result. So if a product is assigned to multiple categories this query does not take that into consideration. However the category id is also stored under the menu item params so we added a couple lines of code

if (!empty($menuData->hikashop_params['category']))
				{
					$category_id = $menuData->hikashop_params['category'];
				}				

And that resolved the problem of jumping categories. See attached doc.

We still had this problems in other languages (we had other probems too) when translating the menu items with Falang. We noticed that when we translate the joomla menu item in Falang, unlike other components, in Falang it was impossible to set the hikashop parmas on a per language basis. There is just the message "You need to save this item before accessing the dacShop options". Looking at the falang_content table we see that the hikashop params saved for the menu items were default params but not the complete hikashop menu params

So this took us the file com_hikashop/fields/selectoptions.php in the frontend. In line 23
if(HIKASHOP_J30 && !in_array(@$_REQUEST['option'],array('com_falang','com_joomfish'))){

explicitly stops the params being shown when translating the menu item. We modified this line to
if(HIKASHOP_J30 && !in_array(@$_REQUEST['option'],array('com_joomfish'))){
so that when you translate the menu items the params are shown and are saved in the falang_content table. This resolved the problem of the categories jumping around in other languages because we can access
$menuData->hikashop_params['category'];
as in other languages. Plus it resolves some inconsistencies in the display between English and other languages.

There are probably very good reasons for not showing the hikashop parmas when translating menu items but in testing so for this has not created any problems. The same for modification of the com_hikashop/views/product/view.html.php file. So for in our testing we have not had any side effects.

Attachments:

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 7 months ago #254987

Hi,

1. I see what you did, but I don't think it would work in all cases. Taking the category from the menu item instead of the category of the current product meansthat you could actually have in the breadcrumb a category which isn't one of the categories of the product. For example, if the category of the menu item is a parent or grand parent of a category of the product.
I would rather recommend to reorder the categories of the product so that the category you want in the breadcrumb is the first one selected in the product edition interface and that will be the one that will be used for the breadcrumb display.

2. In our testing, turning on the options interface for Falang/JoomFish would result in the menu translation edition in Falang to crash. And as it usually isn't necessary to have different options for different languages (you can have different menu items in that case, if that's necessary), we didn't bother looking into the issue further.

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

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
8 years 7 months ago #255052

Hi Nicolas,

1) I have changed the subject because we have set "simplified breadcrumbs" to yes, and the issue we now have is how to display the correct products when scrolling through the product views in a category when one or more products in that category are also assigned to another category. When scrolling through the products, when you arrive at a product which is assigned to more than one category, if $category_id with this database query

			if(empty($category_id)){
				$query='SELECT a.category_id FROM '.dacshop_table('product_category').' AS a WHERE a.product_id='.(int)$product_id.' ORDER BY a.product_category_id ASC';
				$database->setQuery($query);
				$category_id = $database->loadResult();
				$filters['category'] = 'a.category_id = '.(int)$category_id;
			}
it is down to luck for the correct category_id to be found. i.e. return the category id that the user started browsing through. For example the user starts scrolling through the products in category 64, they get to a product which is in category 64 and category 87. Which $category_id is is returned? It could be 64 it could be 87, it depends on which one comes first in the product_category table. So the solutions are 2

1) if there are some products in more than category do not allow users to set "simplified breadcrumbs" to yes, so this way the correct category id can be obtained from the category pathway
2) if "simplified breadcrumbs" is set to yes, then the current category_id needs to be passed to the product view, although how is probably not so straight forward when you in a parent category listing and a single category id is not available

For the issue about falang params I'll start another thread.

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

  • Posts: 83989
  • Thank you received: 13604
  • MODERATOR
8 years 7 months ago #255086

Hi,

It is not down to luck at all. As I explained, the category returned in that case is always the category that you place in first position in your product.
It's like the main image of the product. It's the first image of the listing of the image of the product when you edit it, and that's the one used on the products listing as the main image of the product.
So just make sure that the category you want to be used is the one that is in first place in the product settings.

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

  • Posts: 272
  • Thank you received: 3
  • Hikashop Business
8 years 7 months ago #255385

That is clear now which one comes out now. We will try re-ordering the categories to see if we can find a solution.

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

Time to create page: 0.078 seconds
Powered by Kunena Forum