I installed the module on my site. I have several merchants. Everyone can see the products and the shops.
Currently if I am not connected, everything works correctly. I can see the products and stores of all merchants.
If I connect, nothing works. All pages that display a product or a block containing a product, are in error ("The website encountered an unexpected error, please try again later."). The site is unusable.
I have created a default store (without understanding how to use this feature).
The only way for a connected user to access the products of the shops is to create a shop. If he owns a shop, he can see the products of all the merchants.
This is a big problem and it makes the site totally unusable, even for a user who is not a merchant.
The error only appears if Commerce Marketplace is installed.
I found this :
https://www.drupal.org/project/commerce/issues/2945939
Here is the error message :
TypeError: Argument 2 passed to Drupal\commerce\Context::__construct() must implement interface Drupal\commerce_store\Entity\StoreInterface, null given, called in /home/www.domaine.com/public_html/web/modules/contrib/commerce/modules/order/src/Plugin/Field/FieldFormatter/PriceCalculatedFormatter.php on line 169 in Drupal\commerce\Context->__construct()
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | Capture du 2018-05-20 15-01-55.png | 8.14 KB | zenimagine |
| #3 | Screenshot-2018-5-20 Permissions TESTME.png | 1.77 MB | drugan |
| Capture du 2018-05-19 22-45-48.png | 121.66 KB | zenimagine |
Comments
Comment #2
zenimagine commentedComment #3
drugan commentedI was able to reproduce the issue but, ... only after uninstallng the commerce_marketplace :)
The reason is that when any product variation type has Calculated formatter assigned for the Price field and no global default store assigned then NULL is returned instead of a store object which obviously emits error here:
https://cgit.drupalcode.org/commerce/tree/modules/order/src/Plugin/Field...
UPDATE: Seems that you've found this on the DC issue queue already.
As for the why you have the same issue when the commerce_marketplace is installed, I have no any thought because the module in any case should return some store. Even there is no global default store assigned for some reasons. For example, it was before but then was removed. Or, you've manually edited configuration and removed the UUID value for default_store setting. Most probably the issue is related with a non-store owner user permissions. I can't reproduce the issue when this user is logged in (authenticated user role). They can see all published products of any store or views and blocks containing products. Please, enlarge the screenshot above to see all the roles permissions which I use on my test site.
Comment #4
zenimagine commentedI reproduced your permissions and found the problem.
In your permissions, you have not checked the box "View stores".
If the box is checked, the error appears. If the box is not checked, there is no error, but we do not see any more stores.
You can test this with any user who has any role.
Only the anonymous user does not have this problem.
When "View Stores" is checked for everyone:
- connected user who is not merchant = error with products
- connected user merchant without store = error with products
- connected user merchant with store = it works
So even a customer does not have access to store products and sees an error page.
It seems that Commerce Marketplace requires all users to be a store. Otherwise error.
Comment #6
drugan commentedNow I see. This was a quick fix after the "view own commerce_store" permission has been removed from the DC. I've changed it for "view commerce_store" permission supposing that only store owner (+admin) should see the store information (which could sensible). But, obviously that restricts an admin if they decide to display this info for anyone.
Let's try to use the Marketplace owner role (a MUST for a store owner) for checking if the current store is owned by admin or a regular store owner. Please, pull the latest changes and test if works on your site.
Comment #7
zenimagine commentedI updated the module and clean the cache, but I still have the error.
I need the stores to be posted for everyone. The stores include many fields (logo, description, schedule, address, email, phone number, slideshow, ...) this information should be seen for all.
Comment #9
drugan commentedOK, now I've made so if no one store is resolved for the current user then the first store in the list of a site stores is returned. Please, test it.
Comment #10
zenimagine commentedComment #12
zenimagine commented