Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reindex EAV values only for active storeviews #2651

Merged
merged 5 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/code/core/Mage/Catalog/Model/Product/Indexer/Eav.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class Mage_Catalog_Model_Product_Indexer_Eav extends Mage_Index_Model_Indexer_Ab
],
Mage_Catalog_Model_Convert_Adapter_Product::ENTITY => [
Mage_Index_Model_Event::TYPE_SAVE
],
Mage_Core_Model_Store::ENTITY => [
Mage_Index_Model_Event::TYPE_SAVE
]
];

Expand Down Expand Up @@ -120,6 +123,14 @@ protected function _registerEvent(Mage_Index_Model_Event $event)
}
} elseif ($entity == Mage_Catalog_Model_Convert_Adapter_Product::ENTITY) {
$event->addNewData('catalog_product_eav_reindex_all', true);
} elseif ($entity == Mage_Core_Model_Store::ENTITY) {
if ($event->getType() === Mage_Index_Model_Event::TYPE_SAVE) {
/** @var Mage_Core_Model_Store $store */
$store = $event->getDataObject();
if ($store->getOrigData('is_active') != $store->getIsActive() && $store->getIsActive()) {
$event->getProcess()->changeStatus(Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX);
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ protected function _prepareIndex($entityIds = null, $attributeId = null)
. ' AND pds.store_id=cs.store_id',
['value' => $productValueExpression]
)
->where('pdd.store_id=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
->where('cs.store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
->where('pdd.attribute_id IN(?)', $attrIds)
->where('pdd.store_id = ?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
->where('cs.store_id != ? AND s.is_active=1', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
->where('pdd.attribute_id IN (?)', $attrIds)
->where("{$productValueExpression} IS NOT NULL");

$statusCond = $write->quoteInto('=?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
'1 = 1 AND d.store_id = 0',
['entity_id', 'attribute_id', 'value']
)
->where('s.store_id != 0');
->where('s.store_id != ? AND s.is_active=1', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);

$statusCond = $adapter->quoteInto(' = ?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
$this->_addAttributeToSelect($subSelect, 'status', 'd.entity_id', 's.store_id', $statusCond);
Expand Down Expand Up @@ -211,7 +211,7 @@ protected function _prepareMultiselectIndex($entityIds = null, $attributeId = nu
'pvd.store_id=?',
$adapter->getIfNullSql('pvs.store_id', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
)
->where('cs.store_id!=?', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
->where('cs.store_id != ? AND cs.is_active=1', Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID)
->where('pvd.attribute_id IN(?)', $attrIds);

$statusCond = $adapter->quoteInto('=?', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
Expand Down