4

Sitemaps are generating without a suffix regardless of the settings in the admin.

It appears that when enterprise_url_rewrite was written as a port from core_url_rewrite that the suffix was missed.

Adding suffix awareness to the _getEntityUrl() function for category and product entities in the sitemap resource model seems trivial, but is there something else I am missing or is this a bug that is affecting other people?

For instance for the category (just an example see pastebin link for more info)

protected function _getEntityUrl($row, $entity)
{
    $url = !empty($row['request_path']) ? $row['request_path'] : 'catalog/category/view/id/' . $entity->getId();
    $suffix = Mage::helper('catalog/category')->getCategoryUrlSuffix();
    if ($suffix) {
        $url .= '.' . $suffix;
    }
    return $url;
}

http://pastebin.com/RPWVrhae has a bit more code.

  • I am getting verification this is a bug, and it seems like Kirk has the solution. But please still give us feedback on this if you are seeing it in your 1.13 installs. – Aepod May 29 '14 at 21:19
3

I verified this same issue exists on a separate project also running 1.13.1.0.

Here is a more robust version of the above for anyone implementing this as a patch. This should be applied as a proper local rewrite of Mage_Sitemap_Model_Resource_Catalog_Category and Mage_Sitemap_Model_Resource_Catalog_Product, replacing instances of "category" with "product" in the latter.

  • Plays safer with core code short circuiting if no suffix
  • Only adds suffix to a request path. Will not add to the default url by id
  • Will not add a suffix if suffix is already present - in case there is ever a situation where this happens or if you accidentally end up applying this patch on a Community Edition site, which does not have the issue.
protected function _getEntityUrl($row, $entity)
{
    $suffix = Mage::helper('catalog/category')->getCategoryUrlSuffix();
    if (!$suffix) {
        return parent::_getEntityUrl($row, $entity);
    }

    if (!empty($row['request_path'])) {
        $url = $row['request_path'];
        // Add suffix if not already present
        if (!preg_match('%\.[^/]+$%', $url)) {
            $url .= '.' . $suffix;
        }
    } else {
        // Don't append suffix to default URL paths
        $url = 'catalog/category/view/id/' . $entity->getId();
    }
    return $url;
}
  • I recently discovered that enterprise_url_rewrite contains both urls with suffixes and without. The fix above will still work in this case since it only applies a suffix if one does not already exist. I have yet to determine what the intended behavior of this table is, to be honest, after discovering this. Somewhere, this is a core bug because it's causing multiple people issues with their sitemap. Whether, it's bad data in the table caused by the url migration scripts or bad logic in resource models, I don't know. – kirkmadera Jul 9 '14 at 3:49
1

We are having the same issue for a Magento EE 1.13.0.2 site that we have just launched. No matter what I have attempted to do, I cannot get the suffixes to be added to the sitemap.

I came with the same conclusion as you to modify the Mage_Sitemap_Model_Resource_Catalog_Category and Mage_Sitemap_Model_Resource_Catalog_Product files to add on the suffix if it is set. I am also doing a check that will only add it if the suffix is not present, so if this issue is fixed down the road somewhere else, I do not have to worry about getting extra suffixes added.

If you find a solution, please post it on here so we can figure this out. I will post my solution as well, if I find one.

0

/app/code/core/Enterprise/Catalog/Helper/Category/UrlRewrite.php:

In joinTableToSelect()

This line

'default_urc.category_id = url_rewrite_category.category_id AND default_urc.store_id = 0',

should be:

'default_urc.category_id = main_table.entity_id AND default_urc.store_id = 0',

NOTE the main_table.entity_id reference instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.