olegkoval / magento2-regenerate_url_rewrites

Magento 2 extension which add feature of regenerating a url rewrites of products/categories
Academic Free License v3.0
429 stars 118 forks source link

Script slowing down #130

Open gabrieljadeau opened 4 years ago

gabrieljadeau commented 4 years ago

Describe the bug HI, I am on a MAgento 2.3, with 12412 products in the database. When launching the commande php bin/magento ok:urlrewrites:regenerate --store-id 0, the first 10 seconds, the script generate around 100 products per sec. At 8000 row, the script generate 1 row per sec. Are you aware of this issue?

OvalMedia commented 4 years ago

Just a guess but could it be that your indexes are set to "update on save"? The script is running very fast here, although "only" ~4k products.

gabrieljadeau commented 4 years ago

Hi, tahks for your answer.

I ahav added 2 addAttributeTofilter on the product collection

->addAttributeToFilter('visibility', array('neq' => \Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE))
            ->addAttributeToFilter('status',\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)

to the \OlegKoval\RegenerateUrlRewrites\Model\RegenerateProductRewrites::_getProductsCollection function.

Decreasing from 12k products to 3.8, everyrthing.

Moreover, I think you should skip the generation of the product url if the product name is empty. My client had this issue too, as some

->addAttributeToFilter('name', ['neq' => 'NULL']).

Let me know if that make sense.

BEst,

G