Skip to content

Commit

Permalink
Fix bug with sorting ProductVariations
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
MLindenhofer authored Oct 18, 2023
1 parent 6e0c303 commit c215707
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Extension/ProductVariationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/VariationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function getFormFields($controller = null)
'',
['attribute' => $attribute->Label]
),
$product->possibleValuesForAttributeType($attribute)
$product->possibleValuesForAttributeType($attribute)->sort(['Sort' => 'ASC'])
);

if ($attributeDropdown) {
Expand Down

0 comments on commit c215707

Please sign in to comment.