Error on import: The given entity is not assigned to any store

Created on 16 December 2022, about 2 years ago
Updated 19 January 2024, 11 months ago

Problem/Motivation

While running a migration on a clean setup, I get an error with message 'The given entity is not assigned to any store'. I tracked it down to getContextDetails in src/ContextCreatorTrait.php.

All the solutions I came across did not solve or seem to be for earlier versions of the module.

For testing, I took out all the logic in the method down to code below and that seems to work but obviously not a permanent solutions or for a production environment.

private function getContextDetails(PurchasableEntityInterface $entity) {
    /** @var \Drupal\commerce_store\CurrentStore $currentStore */
    $currentStore = \Drupal::service('commerce_store.current_store');
    $store = $currentStore->getStore();

    $currentUser = \Drupal::currentUser();

    return new Context($currentUser, $store);
}

Steps to reproduce

Run a CSV migration with a simple mapping field_stock: stock

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States j-phat

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024