Skip to content

Magento 2 Short Category & Product URLs Manual

short urls mageworx

Introduction

Magento 2 Short Category & Product URLs decreases the length of the URL improving the product and category pages indexation. The extension provides the versatile optimization technology that allows bypassing the conflicts with new & existing site URLs.

The extension deletes all the subcategories provided in the product and category URL except for the deepest ones.

Requirements and Installation

Short Category & Product URLs supports both Community and Enterprise edition of Magento version 2.2 and 2.3.0. The current version of Magento installed on your website can be found in the lower right corner of any backend page.

Magento 2 Version

Short Category & Product URLs extension has 2 separate ways of installation: via Composer or by copying the code.

Installation Via Composer

  1. Create a folder anywhere on your server (preferably not in the Magento installation directory). Put the zip archive into this folder.

  2. Use any SSH client to connect to your server. Navigate to the root Magento folder. Bear in mind that the user should write permissions to this folder and its subfolders.

  3. Add the folder with the extension's archive as a repository. For this, run the Composer command:

    composer config repositories.mageworx artifact {/ABSOLUTE/PATH/TO/FOLDER}
    

    like

    composer config repositories.mageworx artifact /mageworx/extensions/zip
    

    This command will add these lines to your composer.json file

    "mageworx": {
        "type": "artifact",
        "url": "/mageworx/extensions/zip"
    }
    
  4. Perform the command:

    composer require mageworx/module-shorturlsmeta
    
  5. Clear the compiled code and the cache:

    php bin/magento setup:upgrade
    php bin/magento cache:flush
    

Installation by copying the code

  1. Download the extension's package from your customer account, unzip it.

  2. Use any SSH client to connect to your server. Bear in mind that the user should write permissions to this folder and its subfolders.

  3. Upload all the files and folders from the extension's package to the root Magento folder.

  4. Via SSH, navigate to the root Magento folder and perform the command:

    php bin/magento module:enable MageWorx_ShortUrls
    
  5. Clear the compiled code and cache:

    php bin/magento setup:upgrade
    php bin/magento cache:flush
    

Extension Configuration

Log into the Magento Admin panel and go to MARKETING ⟶ MageWorx Short URLs ⟶ Manage Duplicated URLs.

short urls mageworx

Before enabling the short URLs, the store owner can Skip Redirect Creation. This may be very useful if you just wish to roll out the new website and do not have the old redirects. This action can help you to avoid creating a large number of URL rewrites and potential URL conflicts in the future. Otherwise, we recommend setting this parameter to No.

Click the Apply Short Urls button to initiate the process.

Please note that this operation may be very time-consuming, and in case the website gets stuck, we strongly advise to do it via the console.

This may have 2 outcomes. If no duplicated URLs conflicts have been detected, the message "Short URLs feature was successfully applied" will be shown.

However, if the store owners have many URLs in their websites, it may lead to the number of duplicated that should be fixed to apply the short URLs.

Fixing Short URLs Conflicts

The store owner clicked the Apply Short Urls button to initiate the process and saw the message "We detected the conflict with existing URL(s). Please see the tables below to resolve this problem manually and try again."

This means that the extension while checking the URLs has found the issue with the duplicated structure. Please note that if the errors are shown, the full process of the shortening the URLs has failed. The URL will be changed only if the errors have been fixed.

The workspace shows two grids: for categories and for products.

short urls mageworx

The Category ID (Name) shows the category name that has the conflicts with some other URL.

If the value of the Internal Conflict is Yes, this means that the conflict happens for the new generated URLs. In most cases, this means that the store owner has 2 categories/products with the same name and therefore with the same URL. If this value is No, in most cases, this means that the store has the CMS page with the same name.

If the store owner replaces the URL of the conflicting category or product, but the issue wasn't fixed (e.g., the new URL is used somewhere else), the value of the Bad Replacement column will be Yes.

The Store View shows the store where the problem has occurred. The Action makes it possible to temporary hide this conflict from the grid. Please note that hiding the issue doesn't fix it.

The Category or Product Duplicated URL Path and Category or Product Conflicted URL Key columns show the current URL that is duplicated. The difference between the Path and Key is that the path can include the Product or Category URL Suffix if it is enabled in the Magento configuration.

To change the duplicate URL, click the cell of the Category (or Product) URL Key Replacement, change its value and hit the Save button. After all the changes have been done, click the Apply Short Urls button once again:

short urls mageworx

If everything is correct, the Short URLs will be implemented. If not, you will observe the same grid with the URL values.

To restore the old URL structure, use the Rollback button.

Implementing the Short URLs Via Console

It is possible to implement the short URLs for the website via the console. This may be useful for the websites with a large number of the URLs.

For this, via SSH, navigate to the root Magento folder and perform the command:

php bin/magento shorturls:apply

If the operation has been successful, the output will be:

Short URLs were successfully applied.
Max memory used: 95.711639404297 Mb

with the display of the server memory that has been used.

To skip the redirects creation during this operation, use the flag --skip-redirects.

Otherwise, the status will be:

We detected the conflict with existing URL(s). Please go to your Admin panel=>Marketing=>Manage Duplicated URLs to see the list of duplicates and resolve this problem manually and try again.

If you observe this output, please fix the issues with the duplication.

If you need to rollback the changes, use this command:

php bin/magento shorturls:rollback

Got Questions?

MageWorx offers FREE lifetime support and updates for any extension developed for Magento. Need help with the extensions? Feel free to submit a ticket from https://www.mageworx.com/support/

MageWorx offers outstanding services developing custom-tailored solutions for Magento platform to attain your eCommerce objectives. Our professional impassioned team provides profound and custom oriented development of your project in a short timeframe.