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,
) {
        'e.entity_id = catalog_category_product.product_id AND catalog_category_product.category_id='.$this->layerResolver->get()->getCurrentCategory()->getId(),
    //echo $collection->getSelect();exit;
    return [$collection];

Query result returning correct values

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.

1 Answer 1


Try this : echo "<pre">;print_r($collection->getData());exit;

  • As I mentioned, getting correct result with fig_id . But on category page it's showing memory error. Added screenshot of collection data in question. Jun 25, 2021 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.