Magento 2 : How to run custom script on magento root?

Create a file on magento root and use object manager for using dependencies,

In below example you can see how we get product collection of a particular category using root script.

PHP

After creating the file run the script on browser or using cli

NOTE : This is not a best practice to build any feature in Magento, this is only for debugging purpose or one time code execution.

One thought on “Magento 2 : How to run custom script on magento root?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>