Skip to content

Category data is changed after saving category link in a loop for different stores #22063

@ilnytskyi

Description

@ilnytskyi

Summary (*)

When there is a loop going through a few products and linking those products to categories. Some categories get data copied from another store.

Examples (*)

It's hard to reproduce but imagine that we import/update some product data for different stores. And if we want to link / unlink products to / from "marketing categories" and those categories have different descriptions or other data.
The data may be received from previous store and saved in current store because \Magento\Catalog\Model\CategoryLinkRepository loads categories without specifying store id. And in \Magento\Catalog\Model\CategoryRepository::get all entities are stored as cached in a class property.

Proposed solution

Since there is no any data about a store_id in \Magento\Catalog\Model\CategoryProductLink and column for store id in the table catalog_category_product we can just load a category from the default store to avoid mismatch because of cache key all in CategoryRepository

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrontendComponent: FrontendEvent: dmcdindia1Issue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P3May be fixed according to the position in the backlog.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itstale issue

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions