From e7166ba5d4bda4afeb2a6bb4698e71580c14b431 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Fri, 28 May 2021 13:01:48 +0200 Subject: [PATCH] Drop product.price from /api/ocs/:id/products Its serializer it's only used by this endpoint and app/assets/javascripts/templates/shop_variant.html.haml doesn't rely on the response's product.price but the variant's price. Because our DB schema allows NULL on spree_prices.amount, a master variant without a price can cause the shopfront not to load products. This was the case in https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/60adfcc31cf9740007f82fc9. --- app/serializers/api/product_serializer.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/serializers/api/product_serializer.rb b/app/serializers/api/product_serializer.rb index d97f9967b2..f3ae97b56e 100644 --- a/app/serializers/api/product_serializer.rb +++ b/app/serializers/api/product_serializer.rb @@ -3,7 +3,7 @@ require "open_food_network/scope_variant_to_hub" class Api::ProductSerializer < ActiveModel::Serializer attributes :id, :name, :permalink, :meta_keywords attributes :group_buy, :notes, :description, :description_html - attributes :properties_with_values, :price + attributes :properties_with_values has_many :variants, serializer: Api::VariantSerializer has_one :master, serializer: Api::VariantSerializer @@ -36,14 +36,6 @@ class Api::ProductSerializer < ActiveModel::Serializer options[:master_variants][object.id].andand.first end - def price - if options[:enterprise_fee_calculator] - object.master.price + options[:enterprise_fee_calculator].indexed_fees_for(object.master) - else - object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle]) - end - end - private def sanitizer