akeneo / magento2-connector-community

Akeneo Connector for Magento 2
Open Software License 3.0
82 stars 88 forks source link

Category URL rewrite generation does not work correctly for multiple root categories #55

Closed simonrl closed 4 years ago

simonrl commented 4 years ago

Hi,

we're having an issue with URL rewrite generation.

Environment and configuration

  1. Magento 2.3.1
  2. Akeneo Connector 100.2.3 (current version)
  3. Akeneo CE 3.1.9

Setup

Steps to reproduce

  1. Run a full import where a product that exists in more than 1 website gets imported, and categories get created

Expected result

  1. Categories get created under each root category
  2. The categories have the correct URLs, as defined in the URL key

Actual result

  1. Categories get created, that's fine
  2. Some categories have "-1" or "-2" appended to the URL key

Analysis

I assume the root cause is:

  1. because we have 3 root categories, one category from the PIM gets created 3x
  2. they all have identical names & url keys
  3. if we would create these categories from the Magento-backend, Magento would only create a rewrite for each of the categories in the store where the root category is assigned; this means that each category could have the same url key and identical url rewrites
  4. BUT the connector creates a rewrite for each category in each store, regardless of the root-category-setting.

On a first glance, this seems to happen in Job/Category.php, lines 610ff.

Before generating a URL rewrite, the import should check if $category(line 613) exists unter the root-category that $store (defined in line 588) uses; this could be done by loading the store, and checking the first element of explode('/', $category->getPath()), for example.

Is this correct, or do we have a misconfiguration somewhere?

simonrl commented 4 years ago

Hi, could you have a look please? Thanks! -- Simon

Dnd-Gimix commented 4 years ago

Hi @simonrl ,

Thank you for you interest in the connector.

The issue with the "-1, -2" has been fixed in the last version of the connector : 100.3.1 Please, be sure to check the release notes first before updating your connector : https://github.com/akeneo/magento2-connector-community/blob/master/CHANGELOG.md

Have a good day. Regards,

Dnd-Gimix commented 4 years ago

This issue has been solved, I'm closing it.

CelantEugenio commented 4 years ago

Hi, we have been using the connector since 100.3.4 but we are experiencing the same problem in 100.4.0. Could it have resurfaced in some way?

simonrl commented 4 years ago

Hi @Dnd-Gimix

could you please add a link to a PR / Commit that references this issue?

Thanks a lot Simon