Bulk product edit lists managed products

This commit is contained in:
Rohan Mitchell
2014-09-01 10:13:59 +10:00
parent e0645dfbd9
commit cfb31b46e4
3 changed files with 61 additions and 8 deletions

View File

@@ -19,7 +19,9 @@ module OpenFoodNetwork
end
def managed_products
Spree::Product.managed_by(@user)
managed_enterprise_products_ids = managed_enterprise_products.pluck :id
permitted_enterprise_products_ids = related_enterprise_products.pluck :id
Spree::Product.where('id IN (?)', managed_enterprise_products_ids + permitted_enterprise_products_ids)
end
@@ -37,5 +39,13 @@ module OpenFoodNetwork
Enterprise.where('id IN (?)', parent_ids)
end
def managed_enterprise_products
Spree::Product.managed_by(@user)
end
def related_enterprise_products
Spree::Product.where('supplier_id IN (?)', related_enterprises_with(:manage_products))
end
end
end