Question

How to Log Bundle Product Data (Print Product complete information)In Default Product list.phtml file in magento 2.I am Getting

 foreach ($_productCollection as $_product):  

When I write

echo $_product->getProductUrl()
It is displaying correct product url.But When I tried to print the Entire Product Data by using
print_r($_product->getData());
It is showing Blank Page I changed memory size but again showing blank page only (It is a bundle product) So atleast I want to Log that data in some test.log file for that I used
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(print_r($_product->getData()), true);
but the test.log file is empty.Can anyone Help me on this.

Was it helpful?

Solution

You can try something like as well you can use this to pass data in to log.

        <?php
        echo "<pre>";
        print_r(json_encode($_product->getData()));
        exit;
        ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top