Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

After changing the product another language version becomes uncategorized. #441

Closed
dmytro-kindrat opened this issue Jul 6, 2019 · 8 comments

Comments

@dmytro-kindrat
Copy link

dmytro-kindrat commented Jul 6, 2019

Can you reproduce this issue on default Wordpress theme (eg Storefront)?
Yes

Can you reproduce this issue when all other plugins are disabled except WooCommerce, Polylang and Hyyan WooCommerce Polylang Integration?
Yes

What product versions and settings are you using when this issue occurs?

  • PHP: 7.3.0
  • WordPress: 5.2.2
  • WooCommerce: 3.6.5
  • Polylang
  • Hyyan WooCommerce Polylang Integration: 1.4.3
  • Browser: Firefox 67.0.4

Steps to Reproduce

  1. Go to the Products
  2. Edit product RU
  3. Save product RU
  4. Go to Products and saw an EN version of the product has become uncategorized.
@dmytro-kindrat
Copy link
Author

After saving product RU, the category is not synchronized on EN language, but changed to the category on RU language.

@Jon007
Copy link
Contributor

Jon007 commented Jul 14, 2019

this type of behaviour sounds like your category translations are not linked.
For example, when you save a product in RU, if there is not linked category translation in EN, a copy of the RU will be created in EN and linked, and you may then go and edit the EN translation.
Check in Products, Categories, it is possible to relink categories by opening a category and using the Translations section to link the correct translation.

@dmytro-kindrat
Copy link
Author

I have already tried re-creating the category link, but this did not help.

1s

2

3

4s

5s

6s

7s

@dmytro-kindrat
Copy link
Author

dmytro-kindrat commented Jul 14, 2019

If I create a product in the EN language, the category is synchronized well.
The bug occurs only if I EDIT the product in the default language (RU) and if exist translated version.

@Jon007
Copy link
Contributor

Jon007 commented Jul 14, 2019

I cannot reproduce this, if the categories are set up correctly it normally works fine in whichever language you edit the product.

either the categories are not linked or some of them do not have language set properly.
go to Polylang languages /wp-admin/admin.php?page=mlang and see if there is a notice about some items not have language set, with a link to set them to default language if not set.

@dmytro-kindrat
Copy link
Author

Sorry, I found the reason for this behavior.
I use the Polylang Slug plugin (https://github.com/grappler/polylang-slug).
And the categories in two languages have the same slugs.

For example:
On RU - panties
On EN - panties

If I make slug different, example "panties-ru" and "panties", the synchronisation of categories works fine.

I understand that the categories are synchronized not by the category ID, but by the slugs?

@Jon007
Copy link
Contributor

Jon007 commented Jul 14, 2019

yes, copyTerms in meta.php is currently calling wp_set_object_terms with an array of slugs.
This should be relatively easy to change as wp_set_object_terms should accept an array of ids and the ids are available.

@dmytro-kindrat
Copy link
Author

Thank's!
I edit 409 line meta.php
$new_terms[] = get_term_by('id', $translated_term, $tax)->slug;
to
$new_terms[] = get_term_by('id', $translated_term, $tax)->term_id;

And it worked fine!

Jon007 added a commit that referenced this issue Jul 14, 2019
…uages

synchronise taxonomies by id rather than slug in case the slugs are the
same in different languages
@Jon007 Jon007 closed this as completed Jul 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants