Skip to content

Commit

Permalink
Remove sort method call with RAW SQL from ProductVariationsExtension.…
Browse files Browse the repository at this point in the history
…php as it is no longer supported in CMS5. Add sort call to getFormFields-Method in VariationForm.php
  • Loading branch information
MLindenhofer committed Oct 4, 2023
1 parent f7afd7c commit 154312f
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 154312f

Please sign in to comment.