Shani1351
Shani1351

Reputation: 509

Magento : Use Categories Path for Product URLs configuration doesn’t work

I have a store with a few categories. Most products in the store are in 2-3 categories. I want to have only one url for each product - domain.com/product_name.html. I don't want to have products URLs with the category path in them.

I set “Use Categories Path for Product URLs” to "NO", but when I reindex the Catalog URL Rewrites it creates for each product one regular url (domain.com/product_name.html) and one for each category path (domain.com/category_path/product_name.html).

I've deleted all the product URL rewrites that contain category path, but when I reindex the Catalog URL Rewrites it creates them again.

Isn’t the “Use Categories Path for Product URLs” configuration should prevent this? Am I missing something?

I'm using Magento ver. 1.7.0.0

Thanks

Upvotes: 0

Views: 9008

Answers (4)

rightnowtoday
rightnowtoday

Reputation: 1

For the best SEO practice, We want both canonical meta tags for both categories and products to be enabled. But Why does Magneto doc has recommendation or list as an example for one or the other?

If want search engines to index only pages that have a full category path, do the following: a. Set Use Canonical Link Meta Tag for Categories to “Yes.” b. Set Use Canonical Link Meta Tag for Products to “No.”

If you want search engines to index only product pages, do the following: a. Set Use Canonical Link Meta Tag for Products to “Yes.” b. Set Use Canonical Link Meta Tag for Categories to “No.”

What would be the benefit of one or the other?

I'm guessing for the best practice (in my case, of my client's products, are similar but I'm having them to manually create best URL structure containing unique keywords We are trying to rank for each products), Would below formula be the best option for SEO?

Use Categories Path for Product URLs: No Use Canonical Link Meta Tag For Categories : Yes Use Canonical Link Meta Tag For Products: Yes

Upvotes: 0

DarkCowboy
DarkCowboy

Reputation: 141

Shani1351, I've encountered the same issue than you. I did the same operations: - Set the "Use Categories Path for Product URLs" to "no". - Clear the cache. - Truncate ´core_url_rewrite´. - Clear the cache. - Then check my url rewrites data (from backend). And I saw many url for each product (one url for each related linked category).

BUT if you check on your frontpage, you'll see that there is only one url used by product AS EXPECTED.

I think Magento need to generate the "whole package" urls but do not use them on frontend.


EDIT (more than 3 years later):

My initial answer was wrong. Product urls are returned with category path.

To help magento getting rewrited product url without category path, i recommend you to override the following method as follow (here is a POC, just for demonstration. Don't modify core file, never!):

Mage_Catalog_Model_Product_Url::getUrl()

    public function getUrl(Mage_Catalog_Model_Product $product, $params = array())
{
    $routePath      = '';
    $routeParams    = $params;

    $storeId    = $product->getStoreId();
    if (isset($params['_ignore_category'])) {
        unset($params['_ignore_category']);
        $categoryId = null;
    } else {
        $categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId()
            ? $product->getCategoryId() : null;
    }

    if ($product->hasUrlDataObject()) {
        $requestPath = $product->getUrlDataObject()->getUrlRewrite();
        $routeParams['_store'] = $product->getUrlDataObject()->getStoreId();
    } else {
        $requestPath = $product->getRequestPath();
        if (empty($requestPath) && $requestPath !== false) {
            $idPath = sprintf('product/%d', $product->getEntityId());
            if ($categoryId) {
        //         $idPath = sprintf('%s/%d', $idPath, $categoryId);
            }

Look at the commented line (194 on my CE 1.7.0.2). This is the guilty one!

Just remove this line in your overwrite module:

$idPath = sprintf('%s/%d', $idPath, $categoryId);

Hope it could help someone.

Upvotes: 0

pspahn
pspahn

Reputation: 2790

Depending on your version of Magento and your purpose for setting these URLs, you may want to use the canonical URL feature found in more recent versions.

https://stackoverflow.com/a/13500138/901449

Upvotes: 1

Fabian Blechschmidt
Fabian Blechschmidt

Reputation: 4141

I think you misunderstand the configuration setting.

The setting does exactly what you describe: You have one url per category and one url over all.

The problem is, there is no MAIN category for a product. therefore magento don't know, which category should be used as a url anchor, if you are not on a category view, for example on the homepage in a widget.

If you are in a cagegory view, all the urls should be category/product urls, if you are on the homepage and doing something like described here: http://www.magentocommerce.com/wiki/groups/248/display_products_on_home_page there is no category involed.

Upvotes: 0

Related Questions