Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix generating image urls in the products export (#12542)
Łukasz Adamczyk0600a67ddbd9
diff --git a/core/app/presenters/spree/csv/product_variant_presenter.rb b/core/app/presenters/spree/csv/product_variant_presenter.rbindex 2b7c4ed127..6a2237d791 100644--- a/core/app/presenters/spree/csv/product_variant_presenter.rb+++ b/core/app/presenters/spree/csv/product_variant_presenter.rb@@ -57,6 +57,17 @@ module Spreeattr_accessor :product, :variant, :index, :properties, :taxons, :store, :currency+ ##+ # Generates an array representing a CSV row of product variant data.+ #+ # For the primary variant row (when the index is zero), product-level details such as name,+ # slug, status, vendor and brand names, description, meta tags, and tag/label lists are included.+ # In all cases, variant-specific attributes (e.g., id, SKU, pricing, dimensions, weight,+ # availability dates, inventory count, digital flag, tax category, image URLs via original_url,+ # and the first three option types and corresponding option values) are appended.+ # Additionally, when the index is zero, associated taxons and properties are added.+ #+ # @return [Array] An array containing the combined product and variant CSV data.def callcsv = [product.id,@@ -88,9 +99,9 @@ module Spreevariant.backorderable?,variant.tax_category&.name,variant.digital?,- variant.images[0]&.attachment&.url,- variant.images[1]&.attachment&.url,- variant.images[2]&.attachment&.url,+ variant.images[0]&.original_url,+ variant.images[1]&.original_url,+ variant.images[2]&.original_url,option_type(0)&.name,option_value(option_type(0)),option_type(1)&.name,diff --git a/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb b/core/spec/presenters/spree/csv/product_variant_presenter_spec.rbindex dbd4b6ae52..64ccf15bb5 100644--- a/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb+++ b/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb@@ -8,6 +8,8 @@ RSpec.describe Spree::CSV::ProductVariantPresenter dolet(:taxons) { [] }let(:presenter) { described_class.new(product, variant, 0, properties, taxons, store) }+ let!(:variant_images) { create_list(:image, 3, viewable: variant) }+describe '#call' dosubject { presenter.call }@@ -41,9 +43,9 @@ RSpec.describe Spree::CSV::ProductVariantPresenter doexpect(subject[26]).to eq variant.backorderable?expect(subject[27]).to eq variant.tax_category&.nameexpect(subject[28]).to eq variant.digital?- expect(subject[29]).to eq variant.images[0]&.attachment&.url- expect(subject[30]).to eq variant.images[1]&.attachment&.url- expect(subject[31]).to eq variant.images[2]&.attachment&.url+ expect(subject[29]).to eq variant.images[0].original_url+ expect(subject[30]).to eq variant.images[1].original_url+ expect(subject[31]).to eq variant.images[2].original_urlendcontext 'when index is not zero' do