Skip to content

Commit

Permalink
Fix related products sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
virajrch committed Jul 14, 2024
1 parent 65266d4 commit ab6023e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/spree/product_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def relations_for_relation_type(relation_type)
result = result.merge(self.class.relation_filter) if relation_filter

# make sure results are in same order as related_ids array (position order)
result.where(id: related_ids).order(:position) if result.present?
#result.where(id: related_ids).order(:position) if result.present?
result = result.order(Arel.sql("position(id::text in '#{related_ids.map{|r| r.related_to_id}.join(',')}')")) if result.present?

result
end
Expand Down

0 comments on commit ab6023e

Please sign in to comment.