I am creating custom search based on entries. I need to fetch entries in custom plugin.
For instance like this:
$entries = Entry::find() ->section('sectionName') ->orderBy('fieldName') ->limit(null) ->all();
Have a look here in the documentation (for the code examples you can toggle Twig and PHP view for code examples): https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html
Note that if you add
use craft\elements\Entry; to the top of your plugin file, you can use the
Entry::find() directly, you don't need the namespace prefix like in the examples in the documentation (for instance