3

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.

1 Answer 1

2

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;
        ?>
3

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.