Skip to content

Commit dc4b5f8

Browse files
Fix addIdFilter method
Use case: - Category flat tables are enabled. - Use \Magento\CatalogEvent\Block\Event\Lister or \Magento\CatalogEvent\Block\Widget\Lister, directly or via directive in cms page / block; Application breaks when \Magento\Catalog\Model\ResourceModel\Category\Flat::getCategories is called, with $toLoad == false (so collection is not loaded yet, as it is called indirectly at magento/module-catalog-event/Block/Event/Lister.php:108: $categories = $this->_categoryHelper->getStoreCategories('position', true, false);), then \Magento\Catalog\Model\ResourceModel\Category\Flat\Collection::addIdFilter is called for the unloaded collection (as in magento/module-catalog-event/Block/Event/Lister.php:125: $categories->addIdFilter($eventCollection->getColumnValues('category_id'));), and then it tries to load the collection. It breaks due to ambiguous 'entity_id' field in where clause; field with such name is both found within catalog_category_flat_store_% and url_rewrite tables.
1 parent c3cb46a commit dc4b5f8

File tree

1 file changed

+1
-1
lines changed
  • app/code/Magento/Catalog/Model/ResourceModel/Category/Flat

1 file changed

+1
-1
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Category/Flat/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function addIdFilter($categoryIds)
119119
$condition = ['in' => $ids];
120120
}
121121
}
122-
$this->addFieldToFilter('entity_id', $condition);
122+
$this->addFieldToFilter('main_table.entity_id', $condition);
123123
return $this;
124124
}
125125

0 commit comments

Comments
 (0)