0

I added 2000 + products for magento2 , but Magento2 doesn't reindex index.

Run the reindex command bin/magento indexer:reindex successfully. But my store's front doesn't display product.

My Magento 2 version is 2.0.7 , PHP 7.0.8 ,mysql 5.6

var/log

[2016年09月02日 13:02:02] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4c6b6eeafea885c0042386fe963c20026: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:02] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_40a98983867a1770682b48d9a0ad63441: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:02] main.CRITICAL: Broken reference: the 'catalog.compare.sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exi$
[2016年09月02日 13:02:02] main.CRITICAL: Broken reference: the 'sale.reorder.sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist $
[2016年09月02日 13:02:02] main.CRITICAL: Broken reference: the 'wishlist_sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2016年09月02日 13:02:02] main.CRITICAL: Broken reference: the 'catalog.compare.link' tries to reorder itself towards 'top.links', but their parents are different: 'header.links$
[2016年09月02日 13:02:02] main.CRITICAL: Broken reference: the 'store.settings.currency' tries to reorder itself towards 'store_language', but their parents are different: 'stor$
[2016年09月02日 13:02:03] main.INFO: SELECT `e`.*, IF(at_custom_use_parent_settings.value_id > 0, at_custom_use_parent_settings.value, at_custom_use_parent_settings_default.valu$
 LEFT JOIN `catalog_category_entity_int` AS `at_custom_use_parent_settings_default` ON (`at_custom_use_parent_settings_default`.`entity_id` = `e`.`entity_id`) AND (`at_custo$
 LEFT JOIN `catalog_category_entity_int` AS `at_custom_use_parent_settings` ON (`at_custom_use_parent_settings`.`entity_id` = `e`.`entity_id`) AND (`at_custom_use_parent_set$
[2016年09月02日 13:02:03] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_46f1b068ec7ccf4878f9284dd1137afd1: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:03] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_3e6fe115ba31d500509103893a62701cf: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'header' tries to reorder itself towards 'global.notices', but their parents are different: 'page.wrapper' and 'no$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'page.breadcrumbs' tries to reorder itself towards 'notifications', but their parents are different: 'page.wrapper$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'notification.messages' tries to reorder itself towards 'user', but their parents are different: 'header.inner.rig$
[2016年09月02日 13:02:03] main.INFO: Cache file with merged layout: LAYOUT_adminhtml_STORE1_36f1b068ec7ccf4878f9284dd1137afd1: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:03] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4a456e24e9e0ef145439d526f18fb8b48: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:03] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_4c6690f29cb80c2b881a7311e8632bc3e: Please correct the XML data and try again. [] []
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'catalog.compare.link' tries to reorder itself towards 'top.links', but their parents are different: 'header.links$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'store.settings.currency' tries to reorder itself towards 'store_language', but their parents are different: 'stor$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'product.info.price' tries to reorder itself towards 'product.info.review', but their parents are different: 'prod$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'product.price.final' tries to reorder itself towards 'product.info.sku', but their parents are different: 'produc$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'product.info.social' tries to reorder itself towards 'product.info.overview', but their parents are different: 'p$
[2016年09月02日 13:02:03] main.CRITICAL: Broken reference: the 'bml.right.logo' tries to reorder itself towards 'product.info.addtocart.paypal', but their parents are different:$

debug.log

2016年09月02日 13:04:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_customer_grid_flat_3"},"is_exception":fa$
[2016年09月02日 13:04:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_customer_grid_flat_4"},"is_exception":fa$
[2016年09月02日 13:04:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_customer_grid_flat_1"},"is_exception":fa$
[2016年09月02日 13:04:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_customer_grid_flat_2"},"is_exception":fa$
[2016年09月02日 13:04:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_customer_grid_flat_3"},"is_exception":fa$
[2016年09月02日 13:04:02] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_customer_grid_flat_4"},"is_exception":fa$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_category","catalog_product"],"mode":"matchingAnyTag"},$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"tags":["catalog_category","catalog_product"],"mode":"matchingAnyTag"},$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_1"},"is_ex$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_2"},"is_ex$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_3"},"is_ex$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_4"},"is_ex$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_1"},"is_ex$
[2016年09月02日 13:04:32] main.DEBUG: cache_invalidate: {"method":"GET","url":"http:/","invalidateInfo":{"identifier":"DB_PDO_MYSQL_DDL_catalogsearch_fulltext_scope1_2"},"is_ex$

root@ubuntu:

 /var/www/magento2# php -d memory_limit=8192M bin/magento indexer:reindex && php bin/magento cache:clean
 Customer Grid index has been rebuilt successfully in 00:00:00
 Category Products index has been rebuilt successfully in 00:00:49
 Product Categories index has been rebuilt successfully in 00:00:56
 SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5893-0-1' for key 'PRIMARY', query was: INSERT INTO `catalog_product_index_price_idx` SELECT catalog_product_index_price_final_idx`.`entity_id`,
catalog_product_index_price_final_idx`.`customer_group_id`, catalog_product_index_price_final_idx`.`website_id`, catalog_product_index_price_final_idx`.`tax_class_id`, catalog_product_index_price_final_idx`.`orig_price` AS `price`, catalog_product_index_price_final_idx`.`price` AS `final_price`, catalog_product_index_price_final_idx`.`min_price`, catalog_product_index_price_final_idx`.`max_price`, catalog_product_index_price_final_idx`.`tier_price` FROM catalog_product_index_price_final_idx

My database table "cron_schedule" show message :

indexer_update_all_views
Can't create directory /var/www/magento2/var/generation/Magento/Indexer/Model/Processor/.
indexer_reindex_all_invalid
Can't create directory /var/www/magento2/var/generation/Magento/Indexer/Model/Processor/.
indexer_update_all_views
Can't create directory /var/www/magento2/var/generation/Magento/Indexer/Model/Processor/.
indexer_reindex_all_invalid
Can't create directory /var/www/magento2/var/generation/Magento/Indexer/Model/Processor/.
magento_newrelicreporting_cron
Class Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory does not exist
Can't create directory
sales_send_order_creditmemo_emails
/var/www/magento2/var/generation/Magento/Framework/Translate/ResourceInterface/.
Can't create directory
 sales_send_order_shipment_emails
/var/www/magento2/var/generation/Magento/Framework/Translate/ResourceInterface/.
Can't create directory
sales_send_order_invoice_emails
/var/www/magento2/var/generation/Magento/Framework/Translate/ResourceInterface/.
Can't create directory
sales_send_order_emails
/var/www/magento2/var/generation/Magento/Framework/Translate/ResourceInterface/.
indexer_update_all_views
Can't create directory /var/www/magento2/var/generation/Magento/Indexer/Model/Processor/.
indexer_reindex_all_invalid
Can't create directory /var/www/magento2/var/generation/Magento/Indexer/Model/Processor/.
Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
asked Sep 2, 2016 at 16:49
5
  • You added new product via CSV file? Commented Sep 2, 2016 at 17:30
  • Yes, import product via CSV file. Commented Sep 2, 2016 at 23:22
  • After importing with Csv file, product showed properly? And then, after re-indexing, product didn't display? Commented Sep 3, 2016 at 0:16
  • SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5893-0-1' for key 'PRIMARY', query was: INSERT INTO catalog_product_index_price_idx SELECT catalog_product_index_price_final_idx.entity_id, Commented Sep 3, 2016 at 10:03
  • reset the indexes and then try again Commented Sep 6, 2021 at 11:29

6 Answers 6

0

In the admin got to System->Cache Management, select all cache types and refresh them. Then reload your shop page. Should be there then.

If this does not help, check your products stock. Are your products active, in stock and if you use magento ́s stock management make sure you set the stock amount> 0.

PS: The log outputs you posted look fine! At least that is how they look most of the time in magento even in 100% running shops.

answered Sep 2, 2016 at 23:44
10
  • Before the products are displayed, now the index is broken , I have no problem setting product, before or displayed. Commented Sep 2, 2016 at 23:48
  • How do you know the index is broken? Did you get an error message? Commented Sep 3, 2016 at 0:29
  • use cli bin/magento indexer:reindex && php bin/magento cache:clean,display index has been rebuilt successfully in 0:00 ,But , Don't display product , I cleaned cache . Commented Sep 3, 2016 at 0:33
  • Did you check that you import was used with the correct stock settings? Commented Sep 3, 2016 at 6:14
  • yes, but ,don't diplayed products. Commented Sep 3, 2016 at 8:49
0

First re-index data using Command Prompt

/opt/plesk/php/5.6/bin/php bin/magento indexer:reindex

After this use below content Deploy command.

/opt/plesk/php/5.6/bin/php -dmemory_limit=6g bin/magento setup:static-content:deploy

Then Check it works.

Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
answered Sep 3, 2016 at 5:32
0

There are several issues open issues on Magento Github

#3507

#5627

All of these issues are closed but without solution yet.

If you are now using these blocks I recomended to "reorder" following the instruction or just remove it.

answered Aug 31, 2017 at 14:33
1
  • Please add what version release fixes those bugs, it greatly improves the value of the site, for anyone trying to fix a problem. Commented Dec 14, 2018 at 20:51
0

Run below commands again:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy(if this command don't work than try this: php bin/magento setup:static-content:deploy -f)
php bin/magento indexer:reindex
php bin/magento cache:clean

if it doesn't help then check your directory writes and try running below command in your root magento directory:

chmod -R 0777 pub var generated

And also check quantity and stock status of your products.

answered Aug 8, 2018 at 7:09
0

Maybe the indexes are corrupted, Try first resetting the indexes for the price or better for the whole catalog:

bin/magento indexer:reset

bin/magento indexer:reindex

This should clear all the indexes and redo all of them.

answered Sep 6, 2021 at 11:31
0

you can use this code for re-indexing externally.

<?php 
 use Magento\Framework\App\Bootstrap;
 require __DIR__ . '/../app/bootstrap.php'; 
 set_time_limit(0); 
 $status = "";
 $params = $_SERVER;
 $bootstrap = Bootstrap::create(BP, $params);
 $obj = $bootstrap->getObjectManager();
 $state = $obj->get('Magento\Framework\App\State');
 $state->setAreaCode('frontend');
 $indexer = $obj->get('Magento\Indexer\Model\Indexer\CollectionFactory')->create();
 $ids = $indexer->getAllIds();
 if(isset($_GET["index"])){ 
 $indexerId = $_GET["index"];
 $indexer = $obj->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId);
 $indexer->reindexAll($indexerId); // this reindexes all 
 //$status = 'Succesfully Reindexed - '.$indexerId; 
 header( "Location:/reindex_core.php?status=1" ); 
 } 
 if(isset($_GET["reset"])){ 
 $indexerId = $_GET["reset"];
 $indexer = $obj->get('Magento\Framework\Indexer\IndexerRegistry')->get($indexerId);
 $state = $indexer->getState();
 $state->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID);
 $state->save(); 
 //$status = 'Succesfully resetted - '.$indexerId;
 header( "Location:/reindex_core.php?status=1" ); 
 }
 if(isset($_GET["status"])){ 
 $status = 'Successfully done !!!';
 } 
 ?>
<html>
<head>
 <meta charset="UTF-8">
 <title>EST Reindexer</title>
</head>
<body>
<div class="reindexerBlock">
<h1><a href="/reindex_core.php">Reindexer</a></h1>
<?php if($status): ?>
<p class="alert"><?php echo $status; ?></p>
<?php endif; ?>
<table>
 <tr>
 <th>Indexer Name</th>
 <th>Click to Reindex</th> 
 <th>Current Status</th>
 <th>Click to Reset</th> 
 </tr> 
 <?php foreach ($ids as $id) { 
 $indexer = $obj->get('Magento\Framework\Indexer\IndexerRegistry')->get($id); ?>
 <tr>
 <td><?php echo $id; ?></td>
 <td><a class="statusButton" href="?index=<?php echo $id; ?>">Reindex</a></td> 
 <?php switch ($indexer->getStatus()) {
 case 'valid':
 $style = "green";
 break; 
 default:
 $style = "red";
 break;
 } ?> 
 <td><a class="statusButton" style="background-color:<?php echo $style; ?>">Status: <?php echo $indexer->getStatus(); ?></a></td>
 <td><a onclick="resetChecker()" class="resetChecker statusButton" style="background-color:#ec2029" href="?reset=<?php echo $id; ?>">Reset</a></td>
 </tr>
 <?php } ?>
</table>
<style> 
td { 
 padding: 10px; font-size: 18px;
}
.statusButton {
 background-color: black; 
 border: 2px solid blue;
 color: white;
 padding: 7px 32px;
 text-align: center;
 text-decoration: none;
 display: inline-block;
 font-size: 19px;
}
.alert {
 padding: 20px;
 background-color: #4CAF50;
 color: white;
 margin-bottom: 15px;
}
.reindexerBlock{
 width: 1024px;
 margin: 0 auto;
}
</style>
<script>
function resetChecker(){ 
 var r = confirm("Sure you want to reset?");
 if (r !== true){
 event.preventDefault();
 } 
}
</script> 
</div>
</body>
</html>
Rama Chandran M
3,26515 gold badges24 silver badges38 bronze badges
answered Feb 18, 2022 at 9:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.