Hello,
I started to create a market place on my site and I would like to moderate the stores.
That is to say that when a user creates a store, I do not want it to appear on the site and in the search engines (google, ...).
It must be unpublished or disabled.
If his shop is valid, I activate or publish it and change the role of the user to "Store Owner".
When a node is not published, it is inaccessible. We should do the same with the stores.
If a store is disabled, it must also disable the affected products.
To enable or disable a store, you must add rules.
- If the store contains products, it can not be disabled. You must display a message "To disable this store, you must first disable the associated products."
- If a deactivated product is associated with a disabled store and I want to activate this product. You must display a message "To activate this product, you must first activate the associated store".
If the conditions are not met, the enable / disable check box is not clickable and the warning message is displayed.
I think this feature should be part of Drupal Commerce ..
Stores must have the status "Posted" or "Unpublished".
With a new permission "See all stores" and "See unpublished stores that I own".
When the "Content Moderation" module is stable, it can take into account the stores.
This would be useful for the "Commerce multistore".
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | commerce_store_status_field.patch | 9.1 KB | thanh_uong |
| #25 | 2921000-17.patch | 8.89 KB | dstorozhuk |
| #21 | 2921000-16.patch | 8.77 KB | anpolimus |
Issue fork commerce-2921000
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
zenimagine commentedComment #3
zenimagine commentedComment #4
bojanz commentedSure, why not.
Comment #5
rob c commentedMight need a bit more work, let's see.
Comment #7
rob c commentedNew patch in PR at https://github.com/drupalcommerce/commerce/pull/829
To prevent a similar situation to the 'default' widget description, let's debate the following before this gets committed:
Do you:
A. Publish / Unpublish a store
or
B. Enable / Disable a store
Published is really a 'node'-thing i believe. And it's actually called status in the database (the field).
If we go with B the PR needs a tweak.
TODO: a description might not hurt for the status field?
Comment #8
rob c commentedComment #9
zenimagine commentedI think we should use the terms enable / disable.
Are revisions possible for the shops ?
This will make it possible to moderate the shops with the future module "Moderation" (indispensable for a marketplace).
Comment #10
rob c commentedOk, i'll update the PR.
Not at this time. You might want to create a new issue for this, and not sure what the maintainers think about revisionable stores. (@bojanz what do you think about revisions for stores and the direction of the current PR)
Comment #11
zenimagine commentedCan we create revisions with the stores ?
Comment #12
zenimagine commented"Workflows" and "Content Moderation" modules are now in stable version with Drupal 8.5
Can we moderate the stores ?
Comment #13
mglamanI like "Enable / Disable a store"
This is good if you're bringing a new store online and adding products, but need to reference that store -- and that store can't show up in a store selector, for instance.
Only if we made them support revisions. But I'm not sure the benefit there? In a marketplace I would assume the "store" entity acts like a settings page, not a piece of content.
Comment #14
mglamanHere is a rerolled patch. We no longer need specific actions as core provides them. This also copies the Promotion format for "Status" as a radio of enabled or disabled.
Comment #15
mglamanForgot an upgrade path!
Comment #18
bojanz commentedRetitling.
It's obvious from the discussion above that it makes more sense for a store to be enabled/disabled than published/unpublished.
This is already the case for Promotion, Coupon, ShippingMethod, PriceList, PriceListItem.
As a result of that, we should not be using EntityPublishedInterface and EntityPublishedTrait (just like the other entity types listed above don't).
It might make sense to introduce our own interface/trait, now that it's a common pattern.
The listed entities also don't have a per-bundle setting ("Enable new stores of this type by default"), we always default to TRUE instead, but that's cause they don't use bundle entities at all. Do we still want that feature, or was it just copied from core?
EDIT: Opened #3004026: Add EntityEnabledInterface and EntityEnabledTrait.
Comment #19
bojanz commentedClosed #3004026: Add EntityEnabledInterface and EntityEnabledTrait:
This means that the current patch is close to done. We are missing update code for adding the "published" entity key though.
As for this:
Doesn't hurt to keep it, we have it on product types too.
Comment #20
anpolimusAt one of my projects, I've added state_machine for the organization of moderation workflow.
After last updates, all views are throwing exception with:
The "commerce_store" entity type did not define a "published" key inI've added published key to the store entity and it is fixed my problem.
I see from description that this issue is connected to my problem and fix.
How I can help you to fix finish patch here?
Comment #21
anpolimusRerolled patch against the latest version.
Comment #22
anpolimusComment #24
zenimagine commentedHi, the patch #21 is no longer applicable on the DEV version
Comment #25
dstorozhukUpdate patch.
Comment #26
zenimagine commented@dstorozhuk Great, thank you patch #25 works.
But some functionality (conditions) is missing:
If the store is unpublished, the associated products must be unpublished automatically (or manually with a warning message "To unpublish the store, you must either unpublish the associated products or dissociate them from the store).
If the store is unpublished and the products are associated with more than one store, then the products must have remained unpublished.
Comment #27
mglamanThat's a lot. The products don't need to be unpublished, with the purchased_entity constraint it should just not be "add to cartable" because it has no valid stores. Using event subscribers/hooks you can add a more robust reaction.
Comment #28
zenimagine commentedSince I applied the patch I have this message and all have disappeared
/admin/people/permissions
Comment #29
thanh_uong commentedI rerolled this for Commerce 8.x-2.24, hope someone finds this helpful.
Comment #31
sivaji_ganesh_jojodae commentedWe are requiring this feature in our project. Would like to see this added shortly.
Comment #32
willeaton commentedFrom what I can see, this patch does nothing more than create the field, anyone can do that via the entity system. What we need is to make sure that the commerce module takes this into account in all the important places (checkout, order creation, store_domain resolvers etc
I think this feature makes a lot of sense. You create a store, you have orders associated to a store, then you close it. Is there another way of approaching this?
Comment #33
jsacksick commentedBecause we use the EntityAccessControlHandler and implement the EntityPublishedInterface, we also get access control "for free".
See:
We probably need tests coverage and need to think which code needs to change...
We should try by opening a merge request.
Comment #36
jsacksick commentedI'm going to remove some of the code from the patch, especially this:
We might need a bundleFieldDefinitions() implementation from the Store entity class to properly handle the default status value for bundles.
For now, I'll ignore this.
EDIT: Hm... I just realized this was copied from the ProductTypeForm.
Comment #38
jsacksick commentedSo, I expanded the checkout access logic to ensure access is allowed if the order belongs to a published store. I made changes to the cart provider to flag a cart as non eligible if it belongs to a disabled store.
The product form still allows assigning a product to disabled stores... But perhaps we should keep that? As this technically allows preparing products for a store that will be enabled in the future?
Let's see what the tests say now.
Comment #39
jsacksick commentedI wonder if we need a hook_entity_access() implementation to restrict access to products belonging to a store that is unpublished; At the same time, if a product belongs to multiple stores, perhaps we should still allow access.
Tempted to merge the current MR and implement additional access logic in followup issues. This should be a good starting point.
Comment #41
jsacksick commentedOk, I had started working on denying view access to products belonging to unpublished stores, but I changed my mind after discussing with @rszrama because:
.
Will go ahead and merge the MR as is for now.