Closed
Description
Indexer did not took in to account products belonging to websites. I have fixed it, by editing AbstractEav class function _prepareRelationIndexSelect, by adding join with websites table:
-> join (
['web'=>'catalog_product_website'], 'web.product_id = i.entity_id and web.website_id=cs.website_id', [] )
The whole code is:
protected function _prepareRelationIndexSelect($parentIds = null)
{
$connection = $this->getConnection();
$idxTable = $this->getIdxTable();
$linkField = $this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField();
$select = $connection->select()->from(
['l' => $this->getTable('catalog_product_relation')],
[]
)->joinLeft(
['e' => $this->getTable('catalog_product_entity')],
'e.' . $linkField .' = l.parent_id',
['e.entity_id as parent_id']
)->join(
['cs' => $this->getTable('store')],
'',
[]
)->join(
['i' => $idxTable],
'l.child_id = i.entity_id AND cs.store_id = i.store_id',
['attribute_id', 'store_id', 'value']
)-> join (
['web'=>'catalog_product_website'], 'web.product_id = i.entity_id and web.website_id=cs.website_id', [] // TODO parasyti magento supportui
)->group(
['parent_id', 'i.attribute_id', 'i.store_id', 'i.value']
);
if ($parentIds !== null) {
$select->where('e.entity_id IN(?)', $parentIds);
}
/**
* Add additional external limitation
*/
$this->_eventManager->dispatch(
'prepare_catalog_product_index_select',
[
'select' => $select,
'entity_field' => new \Zend_Db_Expr('l.parent_id'),
'website_field' => new \Zend_Db_Expr('cs.website_id'),
'store_field' => new \Zend_Db_Expr('cs.store_id')
]
);
return $select;
}
I hope you will add this fix in to next magento release ( 2.1.5 ? )