Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Store
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
19 Feb 2018 at 21:58 UTC
Updated:
24 Dec 2019 at 09:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
twiik commentedI get the same error. I upgraded to 2.4 for this exact functionality and it doesn't seem to work.
What do you mean with this:
What's a "null store"? Does that mean you know how how to trigger this error and how to avoid it? I'm on what I assume is a fairly default Commerce setup and I have no idea how to avoid this error or what it means to have a "null store" on a product variation.
Edit: I'm very new to Drupal 8 and OOP in PHP in general so I'm just flailing wildly here, but I assume $store in this example should contain something and not be empty?
I don't really know what it should contain or how it expects to be populated because I don't comprehend the code.
By looking through the admin interface I don't understand how you set a default store and I assume this problem is because I have no default store assigned, but in that case I'd expect nothing to work?
Edit2: I found the checkbox for assigning a default store now. It's on the store edit screen, but it's greyed out and checked because I only have one store so I guess that solves that small mystery. :p
Comment #3
bojanz commentedCommerce can't work without a default store. That's why we disable product add/edit forms when there are no stores.
If you have products, but no stores, then your system is in a broken state.
Go to admin/commerce/config/stores and create a store. If there's one already, edit it and select the "Default" checkbox.
Then resave your products.
Comment #4
twiik commentedIt worked for me after adding a second store. I noted that the "Default" checkbox was checked by default and greyed out even though I was adding a second store, as if Commerce didn't recognize my first store. After I added the second store I could assign my original store to be default again and delete the second store.
I exported my config to see what had changed and default_store was changed in commerce_store.settings.yml even though it actually shouldn't have been. I guess there was something iffy about my config.
But I assure you everything has worked on this site up until this point. I've been adding products, completing checkouts, fulfilling orders etc.
Either way, it works now. Thanks.
Edit: Ohh, and the price formatter works as expected. I can see the promotions on the product page now. Thumbs up!
Comment #5
bojanz commentedThe problem is that the default store UUID is stored in config, so a config (re)deploy can break that connection. A site then has a store, but the default store is not set.
We need to remove the default_store config key, and replace it with an isDefault() flag on the stores themselves.
We should also think about introducing a potential fallback / healing code (if no default store is set, and there is a single store entity, promote it to default)
Comment #6
zenimagine commentedhttps://www.drupal.org/project/commerce_marketplace/issues/2974048
Comment #7
dionsjI took a rough grab at how they fixed it in commerce_marketplace, as linked to by zenimagine.
The patch is likely very rough, but does seem to fix the issue for me locally, so if anyone else if willing to test that would be nice.
Comment #8
oldspot commentedI just experienced the same error while trying to view a product which was working fine up until now.
After reading comment #5 I just realised that beforehand I had done a feature revert which had some commerce changes, so I have gone into the default store edit page and hit Save without changing any values.
The product page loaded fine afterwards without any errors.
If this happens again after a feature revert I will give the patch a test.
Comment #9
drugan commentedThe reason why some people see their store default checkbox checked and even disabled and at the same time have no-default-store errors is that when you had a default store before but then it is disappeared (deleted, feature revert, etc.,), so, wnenever and whichever store edit page you'll visit then this checkbox will be checked for you (the same as when you create the very first store on a site).
The solution is simple: just resave any desired store as it was noticed by @oldspot and the default store will appear internally in config settings, not only visually on a store edit form.
Another solution is just install the https://www.drupal.org/project/commerce_marketplace and additionally to the fixed no-default-store error you'll get a bunch of other useful features. Even if you don't use marketplace strategy. Particularly, I'd recommend to review the admin/commerce/config/stores and admin/commerce/products views provided by the module.
Comment #10
londova commentedI have the same problem; The patch #7 doesn't help.
(I am not able to Remove Orders).
Comment #11
johnpitcairn commentedIn my case the user role needed to be granted the permission "Online: View stores". This permission check appears to be new since 2.11 or so?
Comment #12
joekersWe had users who were getting this error when trying to add a promotion. Granting the ""Online: View stores" permission fixed this.
Comment #13
firfin commentedFor me the solution was to do the 'add a second store, set as default, set first as default, delete second store' trick from #4, thanks Twiik!
Also afterwards in the product type's manage form display settings set the stores field to entity select, following the hint / clatification by Bojanz in #2865233: Provide a more precise error message when a malformed product references no stores #8. Many thanks also.
Comment #14
ljgra commented#12 is what worked for me. Thanks!
Comment #15
handkerchief#12 was the reason for me too. Thank you!
Comment #16
manuel.adan#5 is right. There is a reference in config to a piece of content, which is a clear bug. The patch is just a workaround that I added to one project. I changed the priority to Major since we have an error in all product pages after a simple config update.
Comment #17
bradjones1Updating title to reflect action item per maintainer comment.
Comment #18
czigor commentedThe attached patch removes the whole commerce_store simple config (since default_store is the only key it contains) and adds an is_default base field to the store entity. Falls back to the first store found when there's no default store.
Basically I copied the default profile logic.
No test added.
Comment #20
czigor commentedNo access check needed for default store.
Comment #22
czigor commentedRemoving a line that should be unnecessary but changes our store entity object a bit.
(Instead of
$store->values['is_default'] = ['x-default' => 1]we have$store->values['is_default'] = [0 => ['x-default' => true]].)Comment #24
czigor commentedSame issue as before. Let's reload stores before using them to make sure is_default field is in the correct format.
Comment #25
bojanz commentedPatch no longer applies, needs a reroll. The update functions also need to be renumbered.
We can filter out the current store ID in the query.
Also, this query is missing accessCheck(FALSE).
The main query and the fallback query can be merged into one.
We need to deprecate this method and remove its usages.
Needs a default widget. This will allow us to remove the custom one from StoreForm.
Comment #26
bojanz commentedAddressing my own feedback.
Added a kernel test for the Store entity, we were missing one completely.
Comment #27
bojanz commentedFixing ProductBrowserTestBase.
Comment #28
bojanz commentedCommitted.
Comment #30
zenimagine commented@bojanz I just updated the module but the database refuses to update :
Comment #32
bojanz commentedPushed a followup for #30.
Comment #33
zenimagine commentedThank you I managed to update