- Issue created by @tonytheferg
- Merge request !31Issue #3336898: Allow unpublished variations to be skipped or included → (Merged) created by tonytheferg
This is pretty close except for the views entity reference stuff. If we can work this out, this would address 🐛 Error: Call to a member function getCacheTags() on null in Drupal\commerce_vado\Entity\VadoGroup->getCacheTagsToInvalidate() (line 275 Active as well.
The only thing I notice so far is that after unpublishing or deleting a variation, the price on the add to cart form is cached.
Also not sure how to handle an unpublished product.
This all seems like smart stuff to add though. :)So the entity reference view bit is easily handled by adding a relationship to the variation and making it required, and then adding a filter for published variations.
I mentioned the pricing being cached when variations are deleted, or unpublished, but this is actually the case when prices on individual variations are changed as well. The order processor that calculates the price caches the price. This is a separate issue.
Pulled the check for the variation entity out of the function to make the function better defined, and make the checks more explicit in the code base.
Function:/** * {@inheritdoc} */ public function allowsUnpublishedVariation() { // If the setting is off, and the variation is not published, return FALSE. $allow_unpublished = \Drupal::config('commerce_vado.settings')->get('allow_unpublished_variations'); if (!$allow_unpublished && !$this->getVariation()->isPublished()) { return FALSE; } return TRUE; }
Now you will see the checks like this:
// If the group item doesn't have a variation entity, or if // the group item doesn't allow an unpublished variation, continue. if (!$group_item->getVariation() || !$group_item->allowsUnpublishedVariation()) { continue; }
Cool, all green I feel better about this.
Maybe a couple more tests to go with it.Moved product, variation, and group creation into an new VadoBrowserTestBase file so that we don't need to keep creating and recreating all the above. Also moved display creation to that file as well.
Should make tests a little easier and more performant moving forward.
Sweet. We now have test coverage for unpublished variations and deleted variations both as child add-ons and also in group items.
-
tonytheferg →
committed a27aab5f on 2.0.x
Issue #3336898: Allow unpublished variations to be skipped or included
-
tonytheferg →
committed a27aab5f on 2.0.x