2
votes

I generated a sitemap on Magento's backend. However, the URLS to the product pages contains categories that we don't want.

Example URLS that are being generated that I don't want:

Domain.com  /  cateogry 1  / category 2 / product

The URL format that I want:

Domain.com / product

I turned off category paths on the backend:

System --> Configuration --> Catalog -- >Use Categories Path for Product URLs

but the sitemap is still showing categories.

Is there an option on the backend to remove categories from the xml sitemap? I would rather not have to change each URL manually because there are a lot of products.

Thanks in advance.

1
clear all cache and try againRajeev K Tomy
I tried this and generated another xml sitemap, but it didn't work :/user3896550

1 Answers

0
votes

Quick and simple

magento/module-sitemap/Model/ResourceModel/Catalog/Product.php

Change This

    $connection = $this->getConnection();
    $urlsConfigCondition = '';
    if ($this->isCategoryProductURLsConfig($storeId)) {
        $urlsConfigCondition = 'NOT ';
    }

To Anything really like:

    $connection = $this->getConnection();
    $urlsConfigCondition = '';
    if (2 > 1) {
        $urlsConfigCondition = 'NOT ';
    }

For some reason It's just not picking up configuration even if set in backend

Magento 2.3.1 btw