diff --git a/app/controllers/admin/p_product_refs_controller.rb b/app/controllers/admin/p_product_refs_controller.rb index 641f43b..c187e7f 100644 --- a/app/controllers/admin/p_product_refs_controller.rb +++ b/app/controllers/admin/p_product_refs_controller.rb @@ -18,9 +18,7 @@ class Admin::PProductRefsController < ApplicationController # @purchase_p_product_cats = PProductCat.where(:purchase => true).order(:name).all - global_search_ids = @p_product_refs.ids - p_product_ref_cat_id_ids = @p_product_refs.ids - s_brand_id_ids = @p_product_refs.ids + global_search_ids = p_product_ref_cat_id_ids = s_brand_id_ids = @p_product_refs.ids if params[:search][:global].to_s != "" global_search_ids = PProductRef.global_search(params[:search][:global]).ids @@ -52,13 +50,11 @@ class Admin::PProductRefsController < ApplicationController s_brand_id_ids = @p_product_refs.where(:p_products => {:s_brand_id => params[:search][:s_brand_id]}).ids end + final_ids = global_search_ids & p_product_ref_cat_id_ids & s_brand_id_ids - if params[:search].present? - @p_product_refs = PProductRef.where(id: final_ids) - else - @p_product_refs = PProductRef.joins(:p_product) - end + @p_product_refs = PProductRef.where(id: final_ids) + @p_product_refs = sort_by_sorting(@p_product_refs, "id DESC") respond_to do |format|