The approach however is different: no categories vs multiple category trees.
But the following fix will work by simply checking if the category is set:
$notInWhere = [];
foreach ($categoriesByProduct as $row) {
$categoryList = explode(',', $row['categories']);
foreach ($categoryList as $category) {
// imported product category does not exist in Magento
if (!isset($categoryAkeneo[$category])) {
continue;
}
$data = [
$row['_entity_id'],
$categoryAkeneo[$category]['entity_id'],
];
$productCategoryInsertData[] = $data;
$notInWhere[] = '(' . $row['_entity_id'] . ',' . $categoryAkeneo[$category]['entity_id'] . ')';
}
}
Although the related issue can be fixed with the above, it's probably better to skip the setCategories step altogether,
by checking if the akeneo_connector_entities table contains imported categories, as to not waste resources.
Environment and configuration
Steps to reproduce in Akeneo
Steps to reproduce in Magento
bin/magento akeneo_connector:import --code=category,product
(or schedule the jobs)Expected result
Actual result
This issue is related to https://github.com/akeneo/magento2-connector-community/issues/653.
The approach however is different: no categories vs multiple category trees. But the following fix will work by simply checking if the category is set:
reference
Although the related issue can be fixed with the above, it's probably better to skip the
setCategories
step altogether, by checking if theakeneo_connector_entities
table contains imported categories, as to not waste resources.