- Open on Drupal.org →Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7last update
almost 2 years ago Not currently mergeable. - @neha-mahajan opened merge request.
- 🇮🇳India Sivaji_Ganesh_Jojodae Chennai
We are requiring this feature in our project. Would like to see this added shortly.
- 🇪🇸Spain willeaton
From 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?
- 🇮🇱Israel jsacksick
From 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
Because we use the EntityAccessControlHandler and implement the EntityPublishedInterface, we also get access control "for free".
See:
if ($entity instanceof EntityPublishedInterface && !$entity->isPublished()) { if ($account->id() != $entity->getOwnerId()) { // There's no permission for viewing other user's unpublished entity. return AccessResult::neutral()->cachePerUser(); } $permissions = [ "view own unpublished {$entity->getEntityTypeId()}", ]; $result = AccessResult::allowedIfHasPermissions($account, $permissions)->cachePerUser(); }
We probably need tests coverage and need to think which code needs to change...
We should try by opening a merge request. - 🇮🇱Israel jsacksick
jsacksick → changed the visibility of the branch 2921000-add-a-status to hidden.
- 🇮🇱Israel jsacksick
jsacksick → changed the visibility of the branch 3.x to hidden.
- 🇮🇱Israel jsacksick
I'm going to remove some of the code from the patch, especially this:
+ if ($store->status->value != $value) { + $fields = $this->entityFieldManager->getFieldDefinitions('commerce_store', $this->entity->id()); + $fields['status']->getConfig($this->entity->id())->setDefaultValue($value)->save(); + $this->entityFieldManager->clearCachedFieldDefinitions(); + }
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. - 🇮🇱Israel jsacksick
So, 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.
-
jsacksick →
committed d01774ea on 3.x
Issue #2921000 by jsacksick, Rob C, mglaman, anpolimus, dstorozhuk,...
-
jsacksick →
committed d01774ea on 3.x
- 🇮🇱Israel jsacksick
Ok, I had started working on denying view access to products belonging to unpublished stores, but I changed my mind after discussing with @rszrama because:
A store might be "closed" for business but a product page still be a relevant link to remain active
.
Will go ahead and merge the MR as is for now.