Class: GoogleFeed
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- GoogleFeed
- Defined in:
- app/models/google_feed.rb
Overview
== Schema Information
Table name: google_feeds
Database name: primary
id :bigint not null, primary key
locale :string not null
sku :string not null
target_country_iso :string not null
xml_data :string not null
created_at :datetime not null
updated_at :datetime not null
catalog_id :integer not null
catalog_item_id :integer not null
Indexes
index_google_feeds_on_catalog_id (catalog_id)
index_google_feeds_on_catalog_item_id (catalog_item_id) UNIQUE
Foreign Keys
fk_rails_... (catalog_id => catalogs.id) ON DELETE => cascade
fk_rails_... (catalog_item_id => catalog_items.id) ON DELETE => cascade
Belongs to collapse
Class Method Summary collapse
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Class Method Details
.full_xml(catalog) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/google_feed.rb', line 29 def self.full_xml(catalog) company_name = catalog.company.legal_name locale = catalog.locale_for_catalog product_data = GoogleFeed.where(catalog_id: catalog.id) last_updated = product_data.maximum(:updated_at) || Time.current builder = Nokogiri::XML::Builder.new do |xml| xml.feed(xmlns: "http://www.w3.org/2005/Atom", 'xmlns:g': "http://base.google.com/ns/1.0") do xml.title "#{company_name} Product Feed" xml.link href: "https://www.warmlyyours.com/#{locale}/products", rel: "alternate", type: "text/html" xml.updated last_updated.to_fs(:w3c) xml. do xml.name "WarmlyYours.com" end product_data.pluck(:xml_data).each do |d| xml << d end end end builder.to_xml end |