B2B Suite: No context data found for SalesChannel

This error may happen if you have deleted the headless sales channel, but it seems it is easily fixed by replacing the ID in Defaults.php

141 views
d

By. Jacob

Edited: 2023-08-09 00:35

No context data found for SalesChannel \u002298432def39fc4624b33213a56b8c944d\u0022

I was testing Shopware's B2B Suite (SwagB2bPlatform) when I ran into this problem. Basically installing and activating the plugin would render /admin inaccessible, outputting this cryptic error message in the web browser.

At first this does not really look like a real sales channel ID, but if you pay close attention you will notice that the first and last parts of the SalesChannel (\u0022) is a unicode character code for the quotation mark ("). So, the attentive developer will notice the sales channel causing the error to be 98432def39fc4624b33213a56b8c944 – this is the sales channel ID for the headless sales channel!

If you do a grep for this ID in Shopwares installation folder:

grep -Rl 98432def39fc4624b33213a56b8c944 /var/www/shopware/vendor

You will also find the following interesting comment in vendor/shopware/core/Defaults.php:

/**
  * @deprecated tag:v6.5.0 - Don't rely on this id, the headless sales channel could be deleted.
  */
public const SALES_CHANNEL = '98432def39fc4624b33213a56b8c944d';

Don't rely on this id, the headless sales channel could be deleted.

Developers should not rely on this ID, because the headless sales channel might be deleted! Interesting! This was indeed the case for our installation of Shopware. No idea why it has been deleted though.

Now the question is if we need to somehow re-create the headless sales channel or if we can just replace the ID in Defaults.php with the ID of an existing sales channel? In our staging environment I tried the latter, and so far it seems to work without further incidents. Now we can finally test out the B2B Suite plugin.

Remember, the B2B suite does not have its own settings page in the administration, but instead extends the customer administration.

Don't you just love editing core files?

Links

  1. B2B-Suite - Administration - docs.shopware.com

Tell us what you think:

  1. How to debug issues caused by corrupted custom fields in Shopware 6.
  2. Sometimes we may to manually clear cached Shopware files to fix namespace issues.
  3. How to obtain the currently selected API language from Shopware vue components.
  4. How to access file system paths from storefront twig files in Shopware.
  5. How to get or change the currently selected sales channel in an Shopware sw-sales-channel-switch component.

More in: Shopware