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
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
- B2B-Suite - Administration - docs.shopware.com
Tell us what you think: