From c21570757a3f38431471ebafd8c72c9f71c69e91 Mon Sep 17 00:00:00 2001 From: Martina Lindenhofer <68067510+MLindenhofer@users.noreply.github.com> Date: Wed, 18 Oct 2023 16:31:00 +0200 Subject: [PATCH] Fix bug with sorting ProductVariations * Update CartForm.php add $removecount and $updatecount to extension point to make it possible to create session messages in singular form * Remove sort method call with RAW SQL from ProductVariationsExtension.php as it is no longer supported in CMS5. Add sort call to getFormFields-Method in VariationForm.php * Update VariationForm.php Change notation of sort-params to more readable array notation --- src/Extension/ProductVariationsExtension.php | 4 ++-- src/Forms/VariationForm.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Extension/ProductVariationsExtension.php b/src/Extension/ProductVariationsExtension.php index 3a663b64..90061118 100644 --- a/src/Extension/ProductVariationsExtension.php +++ b/src/Extension/ProductVariationsExtension.php @@ -57,7 +57,7 @@ public function updateCMSFields(FieldList $fields) GridFieldConfig_RecordEditor::create(100) ) ]); - + $variationsGridField->getConfig()->addComponent($sort = new GridFieldOrderableRows('Sort')); if ($this->owner->Variations()->exists()) { @@ -210,7 +210,7 @@ public function possibleValuesForAttributeType($type) '"SilverShop_Variation_AttributeValues"."SilverShop_VariationID" = "SilverShop_Variation"."ID"' )->where( "TypeID = $type AND \"SilverShop_Variation\".\"ProductID\" = " . $this->owner->ID - )->sort('"SilverShop_Variation"."Sort" ASC'); + ); if (!Product::config()->allow_zero_price) { $list = $list->where('"SilverShop_Variation"."Price" > 0'); diff --git a/src/Forms/VariationForm.php b/src/Forms/VariationForm.php index c3079aae..969a7215 100644 --- a/src/Forms/VariationForm.php +++ b/src/Forms/VariationForm.php @@ -130,7 +130,7 @@ protected function getFormFields($controller = null) '', ['attribute' => $attribute->Label] ), - $product->possibleValuesForAttributeType($attribute) + $product->possibleValuesForAttributeType($attribute)->sort(['Sort' => 'ASC']) ); if ($attributeDropdown) {