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/.
6 Answers 6
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.
-
Before the products are displayed, now the index is broken , I have no problem setting product, before or displayed.Patrick-Peng– Patrick-Peng2016年09月02日 23:48:17 +00:00Commented Sep 2, 2016 at 23:48
-
How do you know the index is broken? Did you get an error message?Jérôme– Jérôme2016年09月03日 00:29:44 +00:00Commented 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 .Patrick-Peng– Patrick-Peng2016年09月03日 00:33:06 +00:00Commented Sep 3, 2016 at 0:33
-
Did you check that you import was used with the correct stock settings?Jérôme– Jérôme2016年09月03日 06:14:06 +00:00Commented Sep 3, 2016 at 6:14
-
yes, but ,don't diplayed products.Patrick-Peng– Patrick-Peng2016年09月03日 08:49:19 +00:00Commented Sep 3, 2016 at 8:49
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.
There are several issues open issues on Magento Github
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.
-
Please add what version release fixes those bugs, it greatly improves the value of the site, for anyone trying to fix a problem.J. M. Becker– J. M. Becker2018年12月14日 20:51:33 +00:00Commented Dec 14, 2018 at 20:51
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.
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.
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>
catalog_product_index_price_idxSELECTcatalog_product_index_price_final_idx.entity_id,