1

I have code show detail product extends Magento\Catalog\Block\Product\View. When i wanted show detail product with array, website show error: Fatal error: Allowed memory size of 792723456 bytes exhausted (tried to allocate 390074368 bytes) in C:\xampp\htdocs\demo\app\code\BHT\Demo\view\frontend\templates\demo.phtml on line 5

i have use method getProduct() of Magento\Catalog\Block\Product\View.

Please help.

Block : 
class GetProduct extends \Magento\Catalog\Block\Product\View{

    public function getProductFromCatalog()
    {
        return $this->getProduct();
    }
}

.phtml:
  $product = $block->getProductFromCatalog();

    echo "<pre>";
    print_r($product->getData());
    echo "</pre>";
    die();
Peter
  • 11
  • 4
  • check this out it might help you. https://magento.stackexchange.com/questions/209976/magento-2-2-2-allowed-memory-size-of-792723456-bytes-exhausted-tried-to-alloc – Iago Lima Apr 05 '19 at 17:18
  • Using print_r() on Magento 2 Collection Objects is always a little sketchy because they hold too much data. Try to prepare the data you want to output beforehand and echo them directly. – Tobi Apr 11 '19 at 13:38

1 Answers1

-1

Peter its probably due to your php configuration or you can check the size of this array that you're trying to show, maybe its too big and its breaking you memory limitation.

Check this link out, dude got a problem that look like yours.

https://magento.stackexchange.com/questions/209976/magento-2-2-2-allowed-memory-size-of-792723456-bytes-exhausted-tried-to-alloc