spree-contrib / spree_sitemap

Sitemap Generator for Spree Commerce.

Home Page:http://guides.spreecommerce.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicated entries for products

manmartinez opened this issue · comments

Hi! So I generated my sitemap using rake -s sitemap:refresh and noticed there were two entries per product:

<url>
    <loc>http://shop.demo.org/products/spree-baseball-jersey</loc>
    <lastmod>2014-10-06T17:52:30+00:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.5</priority>
</url>
<url>
    <loc>http://shop.demo.org/products/spree-baseball-jersey</loc>
    <lastmod>2014-10-06T17:52:30+00:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.5</priority>
</url>

This probably has to do with using Spree::Product.active scope since it joins with the master variant and its prices, is there any way to get around this?

The active scope should be fixed to not duplicate entries. Or remove the duplicates here https://github.com/JDutil/spree_sitemap/blob/master/lib/spree_sitemap/spree_defaults.rb#L25

Maybe something like:

active_products = Spree::Product.active.uniq

Yea you should be able to do that at the line I linked to for a workaround, but the proper solution is to fix the active scope to return unique products