cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to bulk re-save all products?

Is there a way to bulk re-save all products?

I got a weird problem in my Magento 2. All products's name are not show in the product page, and the title of these product pages are all 404.

 

I found just by re-saving the product without any change this problem can be solved. 

 

I tried to update attributes for all products, and change their status, both not work. For now, the only way I found that can solve the problem is to click into the edit page of each product, and then click save one by one.

 

So, is there a way that can let me re-save all products?

6 REPLIES 6

Re: Is there a way to bulk re-save all products?

Hello @quizmask

 

have you recently migrate data from 1 to 2?

 

if you want to save  then create one script 

https://mage2-blog.com/magento-2-speed-up-product-save/

 

and save it

 

make sure you will use area code admin, in reference url it is frontend.

 

Hope it will help you.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Is there a way to bulk re-save all products?

Hi @quizmask

 

You can save all product by custom script.

 

Create a custom script on the root of Magento.

 

magentoroot/saveallproduct.php

 

 

<?php

use Magento\Framework\App\Bootstrap;

include 'app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();

$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('adminhtml');

$productCollectionFactory = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory');
$productcollection = $productCollectionFactory->create()
                        ->addAttributeToSelect('*')
                        ->load();

foreach ($productcollection as $product) {
    $productId = $product->getId();
    $product = $objectManager->create('Magento\Catalog\Model\Product');
    $product->load($productId);
    $product->save();
}

then run this custom script on your browser

 

 

www.example.com/saveallproduct.php

 

If Issue Solved, Click Kudos/Accept As solutions.

Re: Is there a way to bulk re-save all products?

Please try to run store indexes reindex manually, maybe that can help you without doing all that saving stuff.

 

php bin/magento indexer:reindex
Did you find it helpful? Please give "Kudos" or "Accept as Solution".
Meet 70+ extensions and templates for M1 & M2 in one place


Re: Is there a way to bulk re-save all products?

@Prince Patel I tried your method, but after run the script, I still see 404 in the product page. Also, I can't make the title show by just saving it in the edit page now. 

 

I find the following error message in the log: (I just copied one, it shows for all products)

====================================================

[2018-08-01 14:28:03] main.DEBUG: cache_invalidate:  {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_product_788"],"mode":"matchingAnyTag"},"is_exception":false} []
[2018-08-01 14:28:03] main.DEBUG: cache_invalidate:  {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_product_788","FPC"],"mode":"matchingTag"},"is_exception":false} []
[2018-08-01 14:28:03] main.DEBUG: cache_invalidate:  {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_product_788"],"mode":"matchingTag"},"is_exception":false} []
[2018-08-01 14:28:03] main.DEBUG: cache_invalidate:  {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_product_788"],"mode":"matchingTag"},"is_exception":false} []
[2018-08-01 14:28:03] main.DEBUG: cache_invalidate:  {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_product_788","FPC"],"mode":"matchingTag"},"is_exception":false} []

Re: Is there a way to bulk re-save all products?

your answer is very helpful for me 
thanks!! 

Re: Is there a way to bulk re-save all products?

And for only configurable products¿?