I am trying to join "catalog_category_product" table custom column to product collection like this,
public function beforeSetCollection(
\Magento\Catalog\Block\Product\ProductList\Toolbar $toolbar,
$collection
) {
$collection->getSelect()->join(
["catalog_category_product"],
'e.entity_id = catalog_category_product.product_id AND catalog_category_product.category_id='.$this->layerResolver->get()->getCurrentCategory()->getId(),
array('fig_id'))->Order('fig_id','ASC');
//echo $collection->getSelect();exit;
return [$collection];
}
Query is returning correct output, but I am getting memory error on frontend category page.
Fatal error: Allowed memory size of 792723456 bytes exhausted (tried to allocate 4096 bytes) in /chroot/home/magento/vendor/magento/framework/DB/Statement/Pdo/Mysql.php on line 91
If anyone knows the answer please do share.