58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'app/models/spree/product_decorator.rb', line 58
def to_channable_product_xml
Nokogiri::XML::Builder.new do |xml|
xml.product do
xml.id id
xml.title "#{name}"
xml.description ActionController::Base.helpers.strip_tags(normalized_description)
xml.link URI.join(::SpreeChannable.configuration.host, "/#{::SpreeChannable.configuration.url_prefix}/" + "#{slug}").to_s
(xml.image_link URI.join(::SpreeChannable.configuration.image_host, images.first.attachment.url(:large)).to_s) if images.any?
xml.condition property('product_condition') || ::SpreeChannable.configuration.product_condition
xml.images do
images.each do |image|
xml.image URI.join(::SpreeChannable.configuration.image_host, image.attachment.url(:large)).to_s
end
end
xml.price price
xml.brand property('brand') || ::SpreeChannable.configuration.brand
xml.categories do
taxons.each do |taxon|
xml.category taxon.self_and_ancestors.collect(&:name).join('|')
end
end
xml.currency Spree::Config.currency
xml.locale I18n.default_locale
xml.gender property('gender') || 'Not set'
xml.delivery_period property('delivery_period') || ::SpreeChannable.configuration.delivery_period
xml.material property('material') || 'Not set'
xml.variants do
(variants.any? ? variants : variants_including_master).each do |variant|
xml.variant do
xml.id variant.id
xml.product_id id
xml.options_text variant.options_text
(xml.image_link URI.join(::SpreeChannable.configuration.image_host, variant.get_images.first.attachment.url(:large)).to_s) unless variant.get_images.empty?
xml.images do
variant.get_images.each do |image|
xml.image URI.join(::SpreeChannable.configuration.image_host, image.attachment.url(:large)).to_s
end
end
xml.availability variant.can_supply?
xml.stock variant.total_on_hand
xml.price variant.price
xml.sale_price variant.respond_to?(:sale_price) ? (variant.sale_price || variant.price) : variant.price
xml.sku variant.sku
xml.currency Spree::Config.currency
xml.locale I18n.default_locale
variant.option_values.each do |option_value|
xml.send(option_value.option_type.name, option_value.presentation)
end
end
end
end
end
end.to_xml
end
|