Move spree/api/base_controller#find_product to api/product_controller where it is used exclusively

Also, product_scope stops being an override
This commit is contained in:
luisramos0
2019-08-01 23:04:07 +01:00
parent f840179573
commit 0d34b607c3
2 changed files with 6 additions and 22 deletions

View File

@@ -94,10 +94,13 @@ module Api
private
# Copied and modified from SpreeApi::BaseController to allow
# enterprise users to access inactive products
def find_product(id)
product_scope.find_by_permalink!(id.to_s)
rescue ActiveRecord::RecordNotFound
product_scope.find(id)
end
def product_scope
# This line modified
if current_api_user.has_spree_role?("admin") || current_api_user.enterprises.present?
scope = Spree::Product
if params[:show_deleted]