olegkoval / magento2-regenerate_url_rewrites

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

Problem while generating url on Magento 2.3.4 #125

Closed samyscoub closed 4 years ago

samyscoub commented 4 years ago

Hello, I've this error on my Magento instance:

$ php bin/magento ok:urlrewrites:regenerate
Regenerating of URL rewrites:

----------------------------------------------------
Please, support me on:
https://www.patreon.com/olegkoval
You can hire me via Upwork:
https://www.upwork.com/o/profiles/users/~01a40656da65c38d3a/
----------------------------------------------------

[Type: product, Store ID: 0, Store View code: admin]:
[============================>                                          ] 41%  2527/6159PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Magento\Catalog\Model\ProductRepository::prepareSku() must be of the type string, null given, called in /var/www/magento/vendor/magento/module-catalog/Model/ProductRepository.php on line 790 and defined in /var/www/magento/vendor/magento/module-catalog/Model/ProductRepository.php:800
Stack trace:
#0 /var/www/magento/vendor/magento/module-catalog/Model/ProductRepository.php(790): Magento\Catalog\Model\ProductRepository->prepareSku(NULL)
#1 /var/www/magento/vendor/magento/module-catalog/Model/ProductRepository.php(349): Magento\Catalog\Model\ProductRepository->saveProductInLocalCache(Object(Magento\Catalog\Model\Product\Interceptor), 'adf0bb68589672e...')
#2 /var/www/magento/vendor/magento/module-catalog/Model/ProductRepository.php(314): Magento\Catalog\Model\ProductRepository->cacheProduct('adf0bb68589672e...', Object(Magento\Catalog\Model\Product\Interceptor))
#3 /var/www/magento/generated/code/Magento/Catalog/Model/ProductRepository/Interceptor.php(37): Magento\Catalo in /var/www/magento/vendor/magento/module-catalog/Model/ProductRepository.php on line 800

Can you help me ?

olegkoval commented 4 years ago

Hello @samyscoub Looks like you have a product with empty SKU (this can happens if product was created programmatically or imported). Sort all products in admin panel by SKU (with empty SKU will be first), find this product(s) and set some value for SKU. Then re-generate Url Rewrites.

samyscoub commented 4 years ago

Hello @olegkoval , I found 4 products without SKU, can you tell me how can I generate automatically new sku for these products ?

olegkoval commented 4 years ago

Hi @samyscoub Open each of this products in admin panel (edit product), then in SKU field set some value and save product.

samyscoub commented 4 years ago

Thx @olegkoval