In Magento 2.4.5, the shop “lost” somehow some associations from configurable to simple product. These simple products are no longer associated with their parent configurable product. The share the same SKU prefix.
I can find them with “Add Products Manually” and filtering for the parent SKU and associate them again to their parent product. But on some products, I run into an error after clicking “Add Products Manually”, as you can see in the screenshot.
Does anybody know what this error is and why it is showing up?
How can I fix this?
I tried several solutions, that I found during my search (Checking if SKUs == null, emptying ui_bookmarks table,…), but found no solution so far.
Additional Question.
Would it be OK (I am avoiding the word safe ;-)) to do this directly in the database? Or does Magento need something else to be also ‘run’ when doing this (for something like finalizing things)?
INSERT INTO catalog_product_super_link (parent_id, product_id)
SELECT (
SELECT entity_id
FROM catalog_product_entity
WHERE sku = 'parentSKU'
), entity_id
FROM catalog_product_entity
WHERE sku LIKE 'parentSKU%'
AND type_id = 'simple'
AND entity_id NOT IN (
SELECT product_id
FROM catalog_product_super_link
WHERE parent_id = (
SELECT entity_id
FROM catalog_product_entity
WHERE sku = 'parentSKU'
)
);
Here is a screenshot of the error I get, when trying to associate the ‘parentless’ simple products.