Magento 2 print product, customer, order object

Conman problem while we are writing some custom code in magento 2 for print any  object. Request go to the infinite look and memory issue.

For resolve the issue i found some workaround debug() method. You can find code in

https://github.com/magento/magento2/blob/2.3-develop/lib/internal/Magento/Framework/DataObject.php#L461-L489

For print any object you can use below code.

$object->debug();

For example if we want to print product object:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get(‘Magento\Catalog\Model\ProductFactory’);
$product->debug();

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.