Add distributor_name_alias to searchable attributes and implement ransacker for filtering line items

This commit is contained in:
Ahmed Ejaz
2025-06-15 18:13:07 +05:00
parent 2f9c856645
commit cd01a27bdd
2 changed files with 7 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
$scope.page = 1
$scope.per_page = $scope.per_page_options[0].id
$scope.filterByVariantId = null
searchThrough = ["order_distributor_name",
searchThrough = ["order_distributor_name_alias",
"order_bill_address_phone",
"order_bill_address_firstname",
"order_bill_address_lastname",

View File

@@ -9,7 +9,7 @@ module Spree
include SetUnusedAddressFields
searchable_attributes :number, :state, :shipment_state, :payment_state, :distributor_id,
:order_cycle_id, :email, :total, :customer_id
:order_cycle_id, :email, :total, :customer_id, :distributor_name_alias
searchable_associations :shipping_method, :bill_address, :distributor
searchable_scopes :complete, :incomplete, :sort_by_billing_address_name_asc,
:sort_by_billing_address_name_desc
@@ -181,6 +181,11 @@ module Spree
scope :by_state, lambda { |state| where(state:) }
scope :not_state, lambda { |state| where.not(state:) }
# This is used to filter line items by the distributor name on BOM page
ransacker :distributor_name_alias do
Arel.sql("distributor.name")
end
def initialize(*_args)
@checkout_processing = nil
@manual_shipping_selection = nil