How to add debug log in the magento 2 using Zend Log?

You can add Debug log in the Magento while you are working with the development feature for your project.

If you need to temporarily debug some of the code while working with the feature, you can directly add the given code snippet to your files to debug or print the log.

You can assume, want to print array data, $data = [‘test1’, ‘test2’];

$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/custom.log');
$zendLogger = new \Zend_Log();
$zendLogger->addWriter($writer);
$zendLogger->info(" Message Log " . print_r($data, true));

While your file runs the above code, In your system, check the root path starting with the var/log folder and a new custom.log file will be generated with your debug log.

This is the basic way you can add your log to the temporary var/log folder while working with the complex features of your project.

How to use foreach loop with the array and objects in knockout js magento?

knockout Javascript with Foreach loops for the observable array and objects with the data-bind property of the DOM tag.

Let’s start with a simple for each loop with an array that contains the numbers only,

JS file contains the knockout declaration of the observable array, called getNumbers property, Continue reading “How to use foreach loop with the array and objects in knockout js magento?”

How to get product custom options list by GraphQl query?

Magento GraphQl query to fetch product custom options list using CustomizableOptionInterface.

The Customizable Option Interface contains basic information about a product’s customizable options.

You can create different types of Custom Options for the product like text field, text area, radio button, dropdown, multi-select, image, file uploading, etc… Continue reading “How to get product custom options list by GraphQl query?”