Coder Social home page Coder Social logo

elgentos / magento2-regenerate-catalog-urls Goto Github PK

View Code? Open in Web Editor NEW
262.0 20.0 70.0 139 KB

This extension adds console commands to be able to regenerate; a product rewrite URL based on its url path; a category rewrite URL based on its url path; a category URL path based on its URL key and its parent categories.

License: MIT License

PHP 100.00%
magento2-module magento2-extension magento2-extension-free

magento2-regenerate-catalog-urls's Introduction

Elgentos Regenerate Catalog URLs

What does it do

This extension adds console commands to be able to regenerate;

  • a product rewrite URL based on its url path;
  • a category rewrite URL based on its url path;
  • a CMS page rewrite URL based on its url path;
  • a category URL path based on its URL key and its parent categories.

Install

Using Composer;

composer require elgentos/regenerate-catalog-urls
php bin/magento setup:upgrade

Or download and copy the src directory into app/code/Elgentos/RegenerateCatalogUrls and run php bin/magento setup:upgrade.

How to use

Usage:
 regenerate:product:url [-s|--store="..."] [pids1] ... [pidsN]
 regenerate:category:url [-s]--store="..."] [-r]--root="..."] [cids1] ... [cidsN]
 regenerate:category:path [-s]--store="..."] [-r]--root="..."] [cids1] ... [cidsN]
 regenerate:cms-page:url [-s]--store="..."] [pids1] ... [pidsN]

Arguments:
 pids                  Products (or Pages) to regenerate
 cids                  Categories to regenerate

Options:
 --store (-s)          Use a specific store (store Id, store code or 'all')
 --root (-r)           Regenerate for root category and its children, ignoring cids. 
 --help (-h)           Display this help message

Eg:

# Regenerate url for all products and the global store
php bin/magento regenerate:product:url

# Regenerate url for products with id (1, 2, 3, 4) for store 1
php bin/magento regenerate:product:url -s1 1 2 3 4

# Regenerate url for all CMS pages
php bin/magento regenerate:cms-page:url -s all

# Regenerate url for root category 4 and its children for store 1
php bin/magento regenerate:category:url -s1 -r4

FAQ

What's the difference between url_key and url_path?

url_key contains the key, like joust-duffle-bag for the product "Joust Duffle Bag". The url_path is generated by taking the url_key and adding the suffix (which for products is stored in catalog/seo/product_url_suffix and defaults to .html). So the url_path would by default become joust-duffle-bag.html. It also adds the category slugs of the parent categories so the url_path might become bags/joust-duffle-bag.html. However, the use of url_path has been deprecated since early Magento 2.1 versions (see here). If you are running on a recent Magento 2 version, you can safely delete those values by running DELETE FROM catalog_product_entity_varchar WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'url_path' AND entity_type_id = 4).

URL paths are still used in categories though, so don't remove those.

Why am I getting a 'Duplicated url' warning when running the command?

If you see this error, you have duplicate url_key values (within a store) in catalog_product_entity_varchar. You can use this extension to check those (and you need to fix them manually): baldwin/magento2-module-url-data-integrity-checker.

magento2-regenerate-catalog-urls's People

Contributors

amenk avatar barryvdh avatar danielimi avatar davidlambauer avatar erfanimani avatar flancer64 avatar hostep avatar iazel avatar justinelst avatar marvinhinz avatar mokadev avatar peterjaap avatar php4umagento avatar pmzandbergen avatar riconeitzel avatar scarbous avatar sprankhub avatar stylecibot avatar t-heuser avatar wouter-toppy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magento2-regenerate-catalog-urls's Issues

The "categoryIds" argument does not exist.

I was having some issues running bin/magento regenerate:category:path in M 2.4.2 getting the error:

The "categoryIds" argument does not exist.

When I checked these files:
RegenerateCategoryPathCommand.php
RegenerateCategoryUrlCommand.php

There is a line that says:
$categoryIds = $input->getArgument('categoryIds');

But the only argument added is "cids" (in the configure function). I changed the line to:
$categoryIds = $input->getArgument('cids');

And everything worked as expected.

Categories in different categorie roots.

If I have 2 different categories with the url-key "example" but they are in different categorie trees, these should both work.

Currently all categories are tried to be generated for each storeview instead of just the categories associated with its root category.

regenerate between id 1 until 100

HI,
thanks in advanced,
I need to regenerate products URL from ID: 1 until 100 ,I mean 1,2,3,...,99,100
how can I do it.
Thank you

Area code not set: Area code must be set before starting a session.

Hi @peterjaap,

First of all thank you for upating

lazel/magento2-regenurl

I know this issue is already solved by you for Magento 2.1.x but I am using Magento2.2.3.

Steps to reproduce

  1. Install your module and enable it.
  2. Setup upgrade using
    php -dmemory_limit=6G bin/magento setup:upgrade -vvv

It shows following error on screen.

Cache cleared successfully
File system cleanup:
magento223/generated/code/Composer
magento223/generated/code/Magento
magento223/generated/code/Symfony
magento223/generated/code/Tatva
Updating modules:
Area code not set: Area code must be set before starting a session.


  [Magento\Framework\Exception\SessionException]
  Area code not set: Area code must be set before starting a session.


Exception trace:
 () at magento223\vendor\magento\framework\Session\SessionManager.php:175
 Magento\Framework\Session\SessionManager->start() at magento223\generated\code\Magento\Catalog\Model\Session\Interceptor.php:50
 Magento\Catalog\Model\Session\Interceptor->start() at magento223\vendor\magento\framework\Session\SessionManager.php:130
 Magento\Framework\Session\SessionManager->__construct() at magento223\generated\code\Magento\Catalog\Model\Session\Interceptor.php:14

 Magento\Catalog\Model\Session\Interceptor->__construct() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory
.php:111
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at magento223\vendor\magento\framework\ObjectManager\Factory\
Dynamic\Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at magento223\vendor\magento\framework\ObjectManager\Facto
ry\AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at magento223\vendor\magento\framework\ObjectMan
ager\Factory\Dynamic\Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at magento223\vendor\magento\framework\ObjectManager\F
actory\Dynamic\Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at magento223\vendor\magento\framework\ObjectManager\Facto
ry\AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at magento223\vendor\magento\framework\ObjectMan
ager\Factory\Dynamic\Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at magento223\vendor\magento\framework\ObjectManager\F
actory\Dynamic\Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
:180
 Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray() at magento223\vendor\magento\framework\ObjectManager\Factory\Ab
stractFactory.php:156
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at magento223\vendor\magento\framework\ObjectManager\Facto
ry\AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at magento223\vendor\magento\framework\ObjectMan
ager\Factory\Dynamic\Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at magento223\vendor\magento\framework\ObjectManager\F
actory\Dynamic\Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:56
 Magento\Framework\ObjectManager\ObjectManager->create() at magento223\vendor\magento\framework\Console\Cli.php:137
 Magento\Framework\Console\Cli->getApplicationCommands() at magento223\vendor\magento\framework\Console\Cli.php:118
 Magento\Framework\Console\Cli->getDefaultCommands() at magento223\vendor\symfony\console\Application.php:1147
 Symfony\Component\Console\Application->init() at magento223\vendor\symfony\console\Application.php:503
 Symfony\Component\Console\Application->find() at magento223\vendor\symfony\console\Application.php:190
 Symfony\Component\Console\Application->doRun() at magento223\vendor\magento\framework\Console\Cli.php:104
 Magento\Framework\Console\Cli->doRun() at magento223\vendor\symfony\console\Application.php:117
 Symfony\Component\Console\Application->run() at magento223\bin\magento:23


  [Magento\Framework\Exception\LocalizedException]
  Area code is not set


Exception trace:
 () at magento223\vendor\magento\framework\App\State.php:152
 Magento\Framework\App\State->getAreaCode() at magento223\vendor\magento\framework\Session\SessionManager.php:173
 Magento\Framework\Session\SessionManager->start() at magento223\generated\code\Magento\Catalog\Model\Session\Interceptor.php:50
 Magento\Catalog\Model\Session\Interceptor->start() at magento223\vendor\magento\framework\Session\SessionManager.php:130
 Magento\Framework\Session\SessionManager->__construct() at magento223\generated\code\Magento\Catalog\Model\Session\Interceptor.php:14

 Magento\Catalog\Model\Session\Interceptor->__construct() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory
.php:111
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at magento223\vendor\magento\framework\ObjectManager\Factory\
Dynamic\Developer.php:66
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at magento223\vendor\magento\framework\ObjectManager\Facto
ry\AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at magento223\vendor\magento\framework\ObjectMan
ager\Factory\Dynamic\Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at magento223\vendor\magento\framework\ObjectManager\F
actory\Dynamic\Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
:144
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at magento223\vendor\magento\framework\ObjectManager\Facto
ry\AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at magento223\vendor\magento\framework\ObjectMan
ager\Factory\Dynamic\Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at magento223\vendor\magento\framework\ObjectManager\F
actory\Dynamic\Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:70
 Magento\Framework\ObjectManager\ObjectManager->get() at magento223\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php
:180
 Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray() at magento223\vendor\magento\framework\ObjectManager\Factory\Ab
stractFactory.php:156
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument() at magento223\vendor\magento\framework\ObjectManager\Facto
ry\AbstractFactory.php:230
 Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime() at magento223\vendor\magento\framework\ObjectMan
ager\Factory\Dynamic\Developer.php:34
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments() at magento223\vendor\magento\framework\ObjectManager\F
actory\Dynamic\Developer.php:59
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at magento223\vendor\magento\framework\ObjectManager\ObjectManage
r.php:56
 Magento\Framework\ObjectManager\ObjectManager->create() at magento223\vendor\magento\framework\Console\Cli.php:137
 Magento\Framework\Console\Cli->getApplicationCommands() at magento223\vendor\magento\framework\Console\Cli.php:118
 Magento\Framework\Console\Cli->getDefaultCommands() at magento223\vendor\symfony\console\Application.php:1147
 Symfony\Component\Console\Application->init() at magento223\vendor\symfony\console\Application.php:503
 Symfony\Component\Console\Application->find() at magento223\vendor\symfony\console\Application.php:190
 Symfony\Component\Console\Application->doRun() at magento223\vendor\magento\framework\Console\Cli.php:104
 Magento\Framework\Console\Cli->doRun() at magento223\vendor\symfony\console\Application.php:117
 Symfony\Component\Console\Application->run() at magento223\bin\magento:23

Let me know if i missing something.

Thank you.

Typed property error on adminhtml regenerate urls

When trying to regenerate product urls via adminhtml the following error occurs:

Typed property Elgentos\RegenerateCatalogUrls\Service\RegenerateProductUrl::$output must not be accessed before initialization

Happens because of this function:

/**
* @param string $message
*
* @return void
*/
private function log(string $message): void
{
if ($this->output !== null) {
$this->output->writeln($message);
}
}

The property must be set to null as default value and then this issue is solved.

With no stores specified - it is doing one Store ID 0 all the time

If you don't specify store as a parameter - looping through the stores is not working at all

My fix for that is -

 foreach ($stores as $store) {
            // If store has been given through option, skip other stores
            if ($storeId != Store::DEFAULT_STORE_ID AND $store->getId() != $storeId) {
                continue;
            }

            $this->collection
                ->addStoreFilter($store->getId())
                ->setStoreId($store->getId())
                ->addFieldToFilter('visibility', ['gt' => Visibility::VISIBILITY_NOT_VISIBLE]);

            $pids = $input->getArgument('pids');
            if (!empty($pids)) {
                $this->collection->addIdFilter($pids);
            }

            $this->collection->addAttributeToSelect(['url_path', 'url_key']);
            $list = $this->collection->load();
            $regenerated = 0;

            /** @var \Magento\Catalog\Model\Product $product */
            foreach ($list as $product) {
                echo 'Regenerating urls for ' . $product->getSku() . ' (' . $product->getId() . ') in store ' . $store->getName() . PHP_EOL;
                $product->setStoreId($store->getId());

                $this->urlPersist->deleteByData([
                    UrlRewrite::ENTITY_ID => $product->getId(),
                    UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
                    UrlRewrite::REDIRECT_TYPE => 0,
                    UrlRewrite::STORE_ID => $store->getId()
                ]);

                $newUrls = $this->productUrlRewriteGenerator->generate($product);
                try {
                    $this->urlPersist->replace($newUrls);
                    $regenerated += count($newUrls);
                } catch (\Exception $e) {
                    $output->writeln(sprintf('<error>Duplicated url for store ID %d, product %d (%s) - %s Generated URLs:' . PHP_EOL . '%s</error>' . PHP_EOL, $store->getId(), $product->getId(), $product->getSku(), $e->getMessage(), implode(PHP_EOL, array_keys($newUrls))));
                }
            }
            $output->writeln('Done regenerating. Regenerated ' . $regenerated . ' urls for store ' . $store->getName());
        }

URL key for specified store already exists when using multiple root categories with same subcategory name

Hi!

im currently trying to figure out why the regenerate command fails, im not so sure if its a magento core bug, or an issue in with the module, or an oversight by me. I can reproduce it in a freshly installed magento store (2.4.6-p3). After setup, i create another root category. Then i create a subcategory in both root categories called A. This works without errors in the backend.

image

Now when running the command bin/magento regenerate:category:url -s all i get the following error:

Regenerating urls for A (4)
Regenerating urls for A (5)
Duplicated url for store ID 2, category 5 (A) - URL key for specified store already exists. Generated URLs:
a.html_2

For reference:

image
image

Magento seems to not create a second entry in the url_rewrite table for the second A category after saving. But after configuring the websites to use one of the root categories, it will create a second entry after recreating the 2 categories.

Bulk product url update not working correctly

Hi guys,

I have found an issue with the bulk product update command ie running '/bin/magento regenerate:product:url'

It currently loops through deleting url's and does it essentially one at a time and takes forever. It seems the issue is in RegenerateProductUrl.php line 101, it isnt clearing the deleteUrls array so its always greater than batch size after the first delete. I added this line

$deleteProducts = []; //reset the array to blank

directly after line 101 and tested it and it solved the issue and helped me fix my live site.

Thanks for the utility it was a great help!

(I dont have access to create a branch otherwise ide have created a PR)

Cheers

Lee

Category Path Generation Randomly Skips Categories

Nice module, helpful.
I have not had a chance to debug why regenerating url_path is not working for some categories. We have 2000 categories. Running different times resulted in different categories not being generated. My theory is that mt_rand(0,1000) sometimes returns "0" which is failing some test. I replaced that with mt_rand(1,1000) + time() [for good measure] and the problem went away.

Duplicated products urls

Hello I've this kind of errors when I ued your module :

php bin/magento regenerate:product:url
...
Duplicated url for store ID 1, product 2418 (REN420M-C3RS) - URL key for specified store already exists. Generated URLs

Can you tell me what to do for this kind of products ?

Regards

Fix inconsistencies between arguments for the different commands

Especially concerning store scoping. To do a full regeneration for a website with two stores, we'll now need to do this mess;

bin/magento regenerate:product:url -s all

bin/magento regenerate:category:url -s storecode1
bin/magento regenerate:category:path -s storecode1

bin/magento regenerate:category:url -s storecode2
bin/magento regenerate:category:path -s storecode2

bin/magento regenerate:cms-page:url -a=1

Missing rewrite for overwritten url_key

I think i have found a scenario where the module is not generating all urls rewrites correctly.

  • Create 2 Websites, 2 Stores and 2 storeviews.
    image

  • Set the 2 stores to be using the same root category.

  • Create a category, and change the scope to one of either storeviews before changing the url key.
    image

  • You should now have 2 url rewrites (and 1 url redirect, but that is not relevant. )
    image

  • Regenerate category urls and see that only 1 of the 2 rewrites are properly created.
    image

  • Confirm by deleting both of the 2 rewrites, and regenerate them. Only the storeview that inherits from global, will have a url rewrite correctly generated.
    image

URL's not regenerating

I installed the module via composer on Magento 2.3.5-p1.

Ran the following commands:
composer require elgentos/regenerate-catalog-urls
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy nl_NL de_DE fr_FR en_US
php bin/magento regenerate:product:url

Got a list of messages that url's were regenerated. After that I reindexed and emptied the cache.

When I checked in admin, the old url's were still in place.

Url generation for invisible products

Dear Elegantos-Team,
it's seems that urls will be generated also for simple products that are not visible individually. Would you accept a pull request to filter those products?

Best Regards
Gordon

Some URL's use path from wrong store view

We are using your module and for most URL's it works great.

However in some cases the path from one store view will be used for all URL's of the product in all Store views. We have checked the configuration of the products and this seems to be correctly setup.

Have you had similar reports in the past? We expect it to be any issue in our setup as the generation works as it should in most cases.

Could you help us? Let me know if I can provide more details.

regenerate:product:url command ignores product visibility

Products that are marked as "Not visible individually" dont need to be regenerated;
Unfortunately, this fork does regenerate these.

If such a product has the same name as another product (whether that one is visible in the store view or not does not matter), this will lead to "URL key for specified store already exists." errors.

Note: tested on Magento 2.1.12

Cannot regenerate category path

Hi,
I am receiving the following error when I run the command:
bin/magento regenerate:category:path

PHP Fatal error:  Uncaught Error: Call to a member function getBackend() on boolean in vendor/magento/module-eav/Model/Entity/AbstractEntity.php:1666
Stack trace:
#0 vendor/magento/module-catalog-url-rewrite/Observer/CategoryUrlPathAutogeneratorObserver.php(99): Magento\Eav\Model\Entity\AbstractEntity->saveAttribute(Object(Magento\Catalog\Model\Category\Interceptor), 'url_path')
#1 vendor/magento/module-catalog-url-rewrite/Observer/CategoryUrlPathAutogeneratorObserver.php(75): Magento\CatalogUrlRewrite\Observer\CategoryUrlPathAutogeneratorObserver->updateUrlKey(Object(Magento\Catalog\Model\Category\Interceptor), 'douche')
#2 vendor/magento/framework/Event/Invoker/InvokerDefault.php in vendor/magento/module-eav/Model/Entity/AbstractEntity.php on line 1666

I am running on version 0.2.4 and my Magento version is 2.3.2 . Do you know why I am running into this error ?

Thank you

Problem regenerating product url

I had some conflicts between some product URL's. I copied product and somehow this created dublicate URL's in DB.

Now i have manually deleted all rows of one specific product (id: 23876) in table url_rewrite, but for some reason when i do php bin/magento regenerate:product:url 23876 it doesn't regenerate URL's. It seems like it cant find the product?
Output is: Done regenerating. Regenerated 0 urls for store Default Store View
It seems to be default output, when the specified product ID doesn't exists..

Any idea why this is happening?

(multiple) Store selection on the command(s) is unclear

When I tried to run regenerate:product:url for 2 stores at the same time,
-s 13,14 displayed an error that the argument was not understood. However,
--store="13 14" cheerfully began re-indexing everything from store-id 0.

I would expect that to either error out with an "you can select only 1 store view at a time" or just a "command not understood"

it generate double .html

at the end of the url, where I actually do not want any extension is generated a double html, like this

.html.html

Stable version

Hi, @peterjaap .

Thanks for the further development of the "Iazel/magento2-regenurl" module. Could you create first release for the module on Github?

I need to

$ composer require elgentos/regenerate-catalog-urls:"dev-master as 0.1.0"

if minimum-stability is not dev in head project's composer.json.

Thanks,

Alex.

Duplicate URLs are wrong

When regenerating URLs for duplicate categories, it throws an error like this:

Duplicated url for store ID 0, category 1278 (Sale & Auslaufartikel) - URL key for specified store already exists. Generated URLs:
sale-auslaufartikel/_1

Shouldn't this duplicate URL be sale-auslaufartikel_1 instead of sale-auslaufartikel/_1?

Question: Regenerate everything

In which order do I have to execute commands to regenerate everything?

regenerate:category:url for all stores?
regenerate:category:path for all stores?
then regenerate:product:url for all stores?

Maybe we should add this to the readme?

Use category path for product URLs

If this option is set to "No" then the module is still generating product rewrites which include the category paths, but it should only create a single URL which doesn't include any category path.

screenshot-www thegreenwellystop co uk-2022 08 25-16_52_37

Regenerate only new products

Hi,
can I regenerate only new (imported) products without URL keys or each run will regenerate all products URL keys?

Thank you.

Tags don't show up on packagist

It is not possible to add this package in any tagged version to a project, only dev-master is available.
Did you push the tags correctly via hooks?

0.4.0 doesnt work with single-store mode

When trying to regenerate the category urls on a 2.4.7-p4 with single store mode enabled, i get"Root category with ID 0, was not found."
It doesnt matter if i pass a store when running the command or not, the store will allways be 0 and the root category will thereby be 0 (which doesnt exists).

Store should be 1 and root category should be 2.

image

This problem happens because 0.4.0 throws an exception if it doesnt find a root category attached to the given store, and 0 is not the correct store.
https://github.com/marvinhinz/magento2-regenerate-catalog-urls/blob/597f4fabfd4d21eb8fcf66cf9cc31f88b59dee97/src/Console/Command/RegenerateCategoryUrlCommand.php#L116-L119

It happens because 0 is hard coded as the store, in case of Single-store mode, which is not correct.
https://github.com/marvinhinz/magento2-regenerate-catalog-urls/blob/9abb064ac2d71b6dc81a37482e4aac118ca58d9e/src/Console/Command/AbstractRegenerateCommand.php#L63-L65

image

An easy solution would just be to change the hardcoded store id from 0 to 1.

Release dev-master

In dev-master, there is a fix for the store Id's in the product url generator. When will this be released?

Product generation generates same URL for all stores

Need to run;

php bin/magento regenerate:product:url --store=en_us
php bin/magento regenerate:product:url --store=en_ca
php bin/magento regenerate:product:url --store=fr_ca
php bin/magento regenerate:product:url --store=es_us
php bin/magento regenerate:product:url --store=pt
php bin/magento regenerate:product:url --store=es
php bin/magento regenerate:product:url --store=fr
php bin/magento regenerate:product:url --store=de
php bin/magento regenerate:product:url --store=it
php bin/magento regenerate:product:url --store=nl
php bin/magento regenerate:product:url --store=en_au
php bin/magento regenerate:product:url --store=en_nz
php bin/magento regenerate:product:url --store=it_ch
php bin/magento regenerate:product:url --store=fr_ch
php bin/magento regenerate:product:url --store=de_ch
php bin/magento regenerate:product:url --store=nl_be
php bin/magento regenerate:product:url --store=fr_be
php bin/magento regenerate:product:url --store=en_uk
php bin/magento regenerate:product:url --store=de_at
php bin/magento regenerate:product:url --store=en_ie

Instead of php bin/magento regenerate:product:url

Emulation dependency injected in the console commands through DI, tries to connect to database

Hi!

There is a dependency injected in the console commands of this module that tries to connect to the database.
Since constructors of console commands are executed whenever bin/magento is ran, this causes an unneeded db connection attempt every single time.

Steps to reproduce:

  • Have a working Magento install (I'm using Magento 2.4.6-p1, but any version will probaby have the same issue)
  • Have elgentos/regenerate-catalog-urls version 0.3.5 installed
  • Change your app/etc/env.php file and use a database user that doesn't exist
  • Run bin/magento

Expected is no error mesages
But we are getting the following at the bottom:

In Abstract.php line 144:

  SQLSTATE[HY000] [1045] Access denied for user 'non-existing-user'@'localhost' (using password: YES)


In Abstract.php line 128:

  SQLSTATE[HY000] [1045] Access denied for user 'non-existing-user'@'localhost' (using password: YES)

After some quick playing around with the dependencies in the console commands of this module, it turns out that it's the dependency Magento\Store\Model\App\Emulation that causes the problem (either directly or through one of it's own dependencies, didn't check further). If I quickly comment out that Emulation dependency in the 3 console commands of this module, then we no longer get that error.

Solution is probably to inject Magento\Store\Model\App\Emulation as a Proxy, that should prevent a database connection to be made upon each bin/magento call.

(you might need magento/magento2#37424 as well, to fully test if this got fixed)

Thanks for considering this fix! ๐Ÿ™‚

Module not compatible to PHP 7.3

Is this module will be compatible with php 7.3 ?

composer require elgentos/regenerate-catalog-urls
Using version ^0.2.4 for elgentos/regenerate-catalog-urls
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - friendsofphp/php-cs-fixer v2.10.5 requires php ^5.6 || >=7.0 <7.3 -> your PHP version (7.3.15) does not satisfy that requirement.
    - friendsofphp/php-cs-fixer v2.10.5 requires php ^5.6 || >=7.0 <7.3 -> your PHP version (7.3.15) does not satisfy that requirement.
    - friendsofphp/php-cs-fixer v2.10.5 requires php ^5.6 || >=7.0 <7.3 -> your PHP version (7.3.15) does not satisfy that requirement.
    - Installation request for friendsofphp/php-cs-fixer (locked at v2.10.5, required as ~2.10.1) -> satisfiable by friendsofphp/php-cs-fixer[v2.10.5].

Multiple Categories in 2.3.5-p1

https://github.com/elgentos/regenerate-catalog-urls/blob/14bb8cefda1dd5054432e4da1f266f23d5565847/Iazel/RegenProductUrl/Console/Command/RegenerateCategoryPathCommand.php#L125

If you give the command multiple identifiers it's expected that it would process more of them

Given:

bin/magento regenerate:category:path "23847,23848,23849,23850,23851,23852,23853,23854,23855,23856,23857,23858,23859,23860,23861,23862,23863,23864,23865,23866,23867,23868,23869,23870,23871,23872,23873,23874,23875,23876,23877,23878,23879,23880,23881,23882,23883,23884,23885,23886,23887,23888,23889,23890,23891,23892,23893,23894,23895,23896,23897,23898,23899,23900,23901,23902,23903,23904,23905,23906,23907,23908,23909,23910,23911,23912,23913,23914,23915,23916,23917,23918,23919,23920,23921,23922,23923,23924,23925,23926,23927,23928,23929,23930,23931,23932,23933,23934,23935,23936,23937,23938,23939,23940,23941,23942,23943,23944,23945,23946" -s 0
        if (!empty($cids)) {
            $categories->addAttributeToFilter('entity_id', ['in' => $cids]);
        }

Outputs:
var_dump($categories->count()) => 1

addAttributeToFilter in filter expects an array, not a comma serperated string
( excuse the ugly array accessor, there's probably a better way )

        if (!empty($cids)) {
            $cids = explode(',', $cids[0]);
            $categories->addAttributeToFilter('entity_id', ['in' => $cids]);
        }

Outputs:
var_dump($categories->count()) => 100

Multi Store site magento 2.3.3 not generate the url correctly

Hello
2020-09-29

When we generate a url for example in the language portgues, instead of generating the url based on the name of the category in Portuguese, generates it with the default language ( english ) and does not change the url field within your language.

BAD URL: /cuchilleria/navajas/navajas -de-barbero.html

Requested URL /cutileria/navaljas/navalhas-do-barbero.html

Duplicated url for store ID, product - URL key for specified store already exists.

Using:

Magento 2.4.3
Module 0.3.3

When trying to bulk regenerate, this error is thrown at the same point every time.

Logically speaking this should mean that there is a duplicate url_key; but have verified in multiple ways that this is not the case.

Specifying the product that supposedly throws the error for regeneration of url works without fail, once more indicating that there is no duplicate url_key for that product

Changing the batch_size will change the supposedly broken product url_key to a different product; indicating that the issue is caused by something else.

This only happens on a fairly large catalog, so that may play a role.

Is there anything I may have overlooked?

.html.html on generation

Much like #16, we are seeing .html.html on generation of urls.

Other modules, like olegkoval/magento2-regenerate-url-rewrites are not causing this issue.

We are on M2.3.3, but I'm fairly certain we saw this issue on earlier versions as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.