Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spree 1.0 Compatibility, spree_essentials_cms Support #7

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactored last_updated to be a defaults method rather than an Active…
…Record class_eval
iloveitaly committed Aug 25, 2012
commit 8cbd5ab91afdd51e733c3164da4236707e53c85b
16 changes: 13 additions & 3 deletions lib/spree/sitemap_generator/defaults.rb
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ def add_password_reset(options={})
def add_products(options={})
active_products = Spree::Product.active

add(products_path, options.merge(:lastmod => active_products.last_updated))
add(products_path, options.merge(:lastmod => last_updated(active_products)))

active_products.each do |product|
opts = options.merge(:lastmod => product.updated_at, :priority => priority(product))
@@ -68,7 +68,7 @@ def add_taxons(options={})
end

def add_taxon(taxon, options={})
opts = options.merge(:lastmod => taxon.products.last_updated, :priority => priority(taxon))
opts = options.merge(:lastmod => last_updated(taxon.products), :priority => priority(taxon))

if gem_available? 'spree_taxon_splash' and taxon.taxon_splash.present?
@video_exclude ||= []
@@ -117,7 +117,17 @@ def video_options(youtube_id, object = false)
def priority(object)
0.5
end
end

def last_updated(object)
if object.is_a? ActiveRecord::Relation
return object.order('updated_at DESC').first.try :updated_at
elsif object.kind_of? ActiveRecord::Base
return object.last_updated
end

Time.now
end
end
end
end

13 changes: 0 additions & 13 deletions lib/spree_sitemap_generator/engine.rb
Original file line number Diff line number Diff line change
@@ -12,19 +12,6 @@ class Engine < Rails::Engine
end

def self.activate
ActiveRecord::Relation.class_eval do
def last_updated
last_update = order('updated_at DESC').first
last_update.try(:updated_at)
end
end

ActiveRecord::Base.class_eval do
def self.last_updated
scoped.last_updated
end
end

SitemapGenerator::Interpreter.send :include, Spree::SitemapGenerator::Defaults
end