# olegkoval/magento2-regenerate-url-rewrites

> Add into Magento 2 a CLI feature which allow to regenerate a Url Rewrites of products and categories

`composer require olegkoval/magento2-regenerate-url-rewrites`

Canonical URL: https://packagento.com/olegkoval/magento2-regenerate-url-rewrites

## At a glance

- **Vendor**: olegkoval (https://packagento.com/olegkoval.md)
- **Latest version**: 1.7.2 — released 2026-04-07
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/olegkoval/magento2-regenerate-url-rewrites and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require olegkoval/magento2-regenerate-url-rewrites:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Add into Magento 2 a CLI feature which allow to regenerate a Url Rewrites of products and categories

## README

“Regenerate Url Rewrites” extension
=====================
Magento 2 "Regenerate Url Rewrites" extension add a CLI feature which allow regenerating a Url rewrites of products/categories in all stores or specific store.
Extension homepage: https://github.com/olegkoval/magento2-regenerate_url_rewrites

### CONTACTS
* Email: olegkoval.ca@gmail.com
* LinkedIn: https://www.linkedin.com/in/oleg-koval-85bb2314/

### DONATIONS / SUPPORT ME ON
* [PayPal](https://www.paypal.com/donate/?hosted_button_id=995MLRKBNY9QQ)
* [Patreon](https://www.patreon.com/olegkoval)

### INSTALLATION

#### COMPOSER INSTALLATION
* run composer command:
>`$> composer require olegkoval/magento2-regenerate-url-rewrites`

#### MANUAL INSTALLATION
* extract files from an archive

* deploy files into Magento2 folder `app/code/OlegKoval/RegenerateUrlRewrites`

#### ENABLE EXTENSION
* enable extension (use Magento 2 command line interface \*):
>`$> php bin/magento module:enable OlegKoval_RegenerateUrlRewrites`

* to make sure that the enabled module is properly registered, run 'setup:upgrade':
>`$> php bin/magento setup:upgrade`

* [if needed] re-compile code and re-deploy static view files:
>`$> php bin/magento setup:di:compile`
>`$> php bin/magento setup:static-content:deploy`


### HOW TO USE IT:
* to regenerate Url Rewrites of all products in all stores (only products) set entity type to "product":
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=product`

because `product` entity type is default — you can skip it:
>`$> php bin/magento ok:urlrewrites:regenerate`

* to regenerate, Url Rewrites in the specific store view (e.g.: store view id is "2") use option `--store-id`:
>`$> php bin/magento ok:urlrewrites:regenerate --store-id=2`

* to regenerate Url Rewrites of some specific product, then use option `product-id` (e.g.: product ID is "122"):
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=product --product-id=122`

or
>`$> php bin/magento ok:urlrewrites:regenerate --product-id=122`

* to regenerate Url Rewrites of specific products range then use option `products-range` (e.g.: regenerate for all products with ID between "101" and "152"):
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=product --products-range=101-152`

\* if in the range you have a gap of ID's (in range 101-152 products with ID's 110, 124, 150 not exists) — do not worry, a script handles this.

or
>`$> php bin/magento ok:urlrewrites:regenerate --products-range=101-152`

* to save a current Url Rewrites (you want to get a new URL rewites and save current) use option `--save-old-urls`:
>`$> php bin/magento ok:urlrewrites:regenerate --save-old-urls`

* to prevent regeneration of "url_key" values (use current "url_key" values) use option `--no-regen-url-key`:
>`$> php bin/magento ok:urlrewrites:regenerate --no-regen-url-key`

* if you do not want to run a full reindex at the end of Url Rewrites generation then use option `--no-reindex`:
>`$> php bin/magento ok:urlrewrites:regenerate --no-reindex`

* if you do not want to run cache:clean at the end of Url Rewrites generation then use option `--no-cache-clean`:
>`$> php bin/magento ok:urlrewrites:regenerate --no-cache-clean`

* if you do not want to run cache:flush at the end of Url Rewrites generation then use option `--no-cache-flush`:
>`$> php bin/magento ok:urlrewrites:regenerate --no-cache-flush`

* if you do not want to display a progress bar in the console then use option `--no-progress`:
>`$> php bin/magento ok:urlrewrites:regenerate --no-progress`

##### REGENERATE URL REWRITES OF CATEGORY
* to regenerate Url Rewrites of all categories in all stores, set an entity type to "category":
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=category`

* to regenerate Url Rewrites of some specific category, then use option `category-id` (e.g.: category ID is "15"):
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=category --category-id=15`

* to regenerate Url Rewrites of specific categories range then use option `categories-range` (e.g.: regenerate for all categories with ID between "4" and "12"):
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=category --categories-range=4-12`

\* if in the range you have a gap of ID's (in range 4-12 category with ID "6" not exists) — do not worry, a script handles this.

\*\* If you use options `--category-id` or `--categories-range` then you can skip option `--entity-type=category` - extension will understand that you want to use a category entity.

#### YOU CAN COMBINE OPTIONS
>`$> php bin/magento ok:urlrewrites:regenerate --store-id=2 --save-old-urls --no-regen-url-key --no-reindex`

#### YOU CANNOT COMBINE THESE OPTIONS
* `--entity-type=product` and `--category-id`/`--categories-range`
* `--entity-type=category` and `--product-id`/`--products-range`
* `--category-id` and/or `--categories-range` and/or `--product-id` and/or `--products-range`

#### DEPRECATED OPTIONS
* `--check-use-category-in-product-url` — extension uses a built-in Magento Url Rewrites generator which check this option in any way.

#### EXAMPLES OF USAGE
* Regenerate Url Rewrites for product with ID "38" in store with ID "3":
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=product --store-id=3 --product-id=38`

or
>`$> php bin/magento ok:urlrewrites:regenerate --store-id=3 --product-id=38`

* Regenerate Url Rewrites for products with ID's 5,6,7,8,9,10,11,12 in store with ID "2" and do not run full reindex at the end of process:
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=product --store-id=2 --products-range=5-12 --no-reindex`

* Regenerate Url Rewrites for category with ID "22" in all stores and save current Url Rewrites:
>`$> php bin/magento ok:urlrewrites:regenerate --entity-type=category --category-id=22 --save-old-urls`

_(README truncated for .md surface. Full README on https://packagento.com/olegkoval/magento2-regenerate-url-rewrites.)_

## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### [1.7.2] - 2026-03-31
#### Changed
- fixed deprecated functionality: ctype_digit()
- improved SQL safety in URL rewrite regeneration queries
- fixed SQL escaping in URL rewrite cleanup logic
- fixed _clearRequestPath() to correctly handle multiple consecutive slashes
- removed dead code from category URL rewrite model
- display validation errors before command failure
- display a completed progress bar for empty product/category collections
- normalized line endings to LF

### [1.7.1] - 2025-05-30
#### Changed
- adapted for compatibility with PHP 8.4 (deprecated implicitly nullable types)

### [1.7.0] - 2025-04-15
#### Changed
- adapted for compatibility with Magento 2.4.7-p4
- adapted the composer.json file to be compatible with Composer 2

### [1.6.2] - 2023-10-10
#### Changed
- fixed Symfony Command constant issue
- exclude non visible products from url regeneration

### [1.6.1] - 2023-08-24
#### Changed
- fixed compatibility with Symfony Console 5 and Magento 2.4.6
- updated contact email to Gmail email (my own domain olegkoval.com was stolen)

### [1.6.0] - 2021-01-27
#### Changed
- adapted to Magento 2.3.5
- fixed incorrect generation when URL suffix is slash

### [1.5.6] - 2020-04-13
#### Changed
- updated logic of "cleaning" of Url Rewrites and duplications check

### [1.5.5] - 2020-04-02
#### Changed
- updated logic of Url Rewrite regeneration via category entity
- fixed compilation issue in helper

### [1.5.4] - 2020-03-21
#### Changed
- fixed issue of non-empty/non-false "request_path" of product entity.
- modified logic of Url Rewrite db table updates

### [1.5.3] - 2020-03-20
#### Changed
- updated Url Rewrite preparing function
- updated logic of Url Rewrite regeneration via category entity
- updated save logic

### [1.5.2] - 2020-03-18
#### Changed
- updated logic of Url Rewrite regeneration via category entity
- CLI options logic optimized (for category entity)

### [1.5.1] - 2020-03-08
#### Changed
- fixed issue of url_key and url rewrites regeneration based on product name value

### [1.5.0] - 2020-02-26
#### Changed
- revised and restructured code
- modified functional logic of extension
- removed option "--check-use-category-in-product-url"

### [1.4.3] - 2019-05-12
#### Added
- new option "no-regen-url-key"

#### Changed
- fixed a "typo" issue

### [1.4.2] - 2019-04-04
#### Added
- new option "--check-use-category-in-product-url"
- info into log about conflicted URL Rewrites

#### Changed
- fixed logical issues in url_key regeneration
- a fix for category/products rewrites for multistore
- fixed issue of division by zero in progress bar
- update the url_key regeneration behavior to use UrlPathGenerators
- modified logic of displaying console messages (notifications, errors, exceptions...)

### [1.4.1] - 2019-02-20
#### Changed
- fixed the issue of removing previously added URL rewrites of product when the same URL key exists;
- modified progress bar

### [1.4.0] - 2019-02-11
#### Added
- new option "--entity-type"
- new option "--products-range"
- new option "--product-id"
- new option "--category-range"
- new option "--category-id"

#### Changed
- revised and restructured code
- modified logic of url rewrites regeneration
- removed "--clean-url-key"

### [1.3.1] - 2018-11-14
#### Changed
- fixed issue of empty product URL keys
- fixed double slashes issue
- update category attributes via resource saveAttribute()
- use proxy for CategoryUrlPathGenerator

### [1.3.0] - 2018-10-29
#### Added
- new option "--no-cache-clean"
- new option "--no-cache-flush"
- new option "--no-progress"
- new option "--no-clean-url-key"

#### Changed
- optimized code
- modified logic of url rewrites regeneration
- fixed issue of store filter in a category collection

_(Changelog truncated for .md surface. Full history on https://packagento.com/olegkoval/magento2-regenerate-url-rewrites.)_

## Recent Versions

| Version | Released |
|---|---|
| 1.7.2 | 2026-04-07 |
| 1.7.1 | 2025-05-30 |
| 1.7.0 | 2025-04-17 |
| 1.6.2 | 2023-10-10 |
| 1.6.1 | 2023-08-24 |
| 1.6.0 | 2021-01-27 |
| 1.5.6 | 2020-04-14 |
| 1.5.5 | 2020-04-02 |
| 1.5.4 | 2020-03-21 |
| 1.5.3 | 2020-03-21 |

Showing 10 of 31 versions. Full release history on https://packagento.com/olegkoval/magento2-regenerate-url-rewrites.

## Quality

Latest release (1.7.2) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | Pass | – |
| 2.4.9 | – | – | Pass | 1 |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Fail | 71 | 12 errors, 59 warnings (ruleset: Magento2) — 19 auto-fixable with phpcbf |
| PHPMD | Warning | 7 | 7 rule violations (EmptyCatchBlock:2, UnusedLocalVariable:1, CyclomaticComplexity:1, NPathComplexity:1, ExcessiveMethodLength:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Pass | 0 |  |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 1 | 1 | – | – |
| 2.4.8 | – | 1 | 1 | – |
| 2.4.9 | – | – | 1 | 1 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["olegkoval/magento2-regenerate-url-rewrites"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

olegkoval is a Magento 2 vendor on Packagento. See https://packagento.com/olegkoval.md for their full catalogue.

