I'm building my first Magento 2 module, and I'm a bit stuck.
First of all, this is what I have so far (I'm still fixing the coding standards on all the pages). https://github.com/moloni/magento2
I have a doubt about something a bit simple... How do I get the first row of the table I created?
I made a repository, created all the files for the Tokens model, and I can access the first row using the following:
$collection = $this->getCollection();
if ($collection->getSize()) {
$this->tokensRow = $collection->getFirstItem();
}
But, since the method getCollection
says it will be deprecated, what can I use to the get the first row of a table?
Every method I saw was using the getCollection mehtod, and that's why my doubt.
Also, if I want to read the first row and update the row if it exists, or create a new one if it does not, how can I do so without the getCollection
?
Still learning how to properly code for Magento 2.