Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category and product entity_id and row_id could be not consistant #647

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mpasquin
Copy link

@mpasquin mpasquin commented Jun 7, 2023

Category and product row_id is always null when the entity is created. They can diverge too.

Insert query shoud be

INSERT INTO `catalog_product_entity` (`entity_id`, `attribute_set_id`, `type_id`, `sku`, `updated_at`, `row_id`)
SELECT `tmp_akeneo_connector_entities_product`.`_entity_id`        AS `entity_id`,
       `tmp_akeneo_connector_entities_product`.`_attribute_set_id` AS `attribute_set_id`,
       `tmp_akeneo_connector_entities_product`.`_type_id`          AS `type_id`,
       `tmp_akeneo_connector_entities_product`.`identifier`        AS `sku`,
       NOW()                                                       AS `updated_at`,
       IFNULL(p.row_id, _entity_id)                                AS `row_id`
FROM `tmp_akeneo_connector_entities_product`
LEFT JOIN `catalog_product_entity` AS `p`
    ON _entity_id = p.entity_id
LEFT JOIN `staging_update` AS `s`
    ON p.created_in = s.id
WHERE (s.is_rollback = 1 OR s.id IS NULL)
ON DUPLICATE KEY UPDATE `entity_id`        = VALUES(`entity_id`),
                        `attribute_set_id` = VALUES(`attribute_set_id`),
                        `type_id`          = VALUES(`type_id`),
                        `sku`              = VALUES(`sku`),
                        `updated_at`       = VALUES(`updated_at`),
                        `row_id`           = VALUES(`row_id`);

instead of

INSERT INTO `catalog_product_entity` (`entity_id`, `attribute_set_id`, `type_id`, `sku`, `updated_at`, `row_id`)
SELECT `tmp_akeneo_connector_entities_product`.`_entity_id`        AS `entity_id`,
       `tmp_akeneo_connector_entities_product`.`_attribute_set_id` AS `attribute_set_id`,
       `tmp_akeneo_connector_entities_product`.`_type_id`          AS `type_id`,
       `tmp_akeneo_connector_entities_product`.`identifier`        AS `sku`,
       NOW()                                                       AS `updated_at`,
       `p`.`row_id`
FROM `tmp_akeneo_connector_entities_product`
LEFT JOIN `catalog_product_entity` AS `p`
    ON _entity_id = p.entity_id
LEFT JOIN `staging_update` AS `s`
    ON p.created_in = s.id
WHERE (s.is_rollback = 1 OR s.id IS NULL)
ON DUPLICATE KEY UPDATE `entity_id`        = VALUES(`entity_id`),
                        `attribute_set_id` = VALUES(`attribute_set_id`),
                        `type_id`          = VALUES(`type_id`),
                        `sku`              = VALUES(`sku`),
                        `updated_at`       = VALUES(`updated_at`),
                        `row_id`           = VALUES(`row_id`);

In select columns, it is always `p`.`row_id`.  
It should be IFNULL(p.row_id, _entity_id) AS `row_id`.
In select columns, it is always `p`.`row_id`.  
It should be IFNULL(p.row_id, _entity_id) AS `row_id`.
@mpasquin mpasquin changed the base branch from master to develop June 7, 2023 12:13
@mpasquin mpasquin changed the base branch from develop to master June 7, 2023 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant