I'm trying to fetch information of certain products, just not sure what function is available. I was wondering if there is a list of all magento 2 functions, like getName(), getPrice() etc.., then I can choose which I can use easily. thanks
Its unclear to me what you are asking for If you want to know what a product model functions are available to use you can refer to
See in Git
All Magento Models extend the
\Magento\Framework\DataObject class. This class has the magic method
Long story short, it means that models don't necessarily have to have all the methods defined. Every column's getter and setter is already defined in the model. So for example, if there's a model
Phone defined for a table
my_phones having columns
price, then the
Phone class would have functions
setPrice($price) functions predefined, without us explicity defining it (notice the snake_case to CamelCase transformation while forming the method names).
This becomes more complicated when we deal with EAV models (like the Product model), since we don't know all the "columns" that it's fetching.
For an EAV collection, we can use the
addFieldToSelect() method to add "columns" to retrieve.
And for models, we can always call the
getData() method to fetch all the data values.
So to answer your question, no there isn't any list of methods, because even Magento doesn't know all the methods required, since the admin can add new attributes later on. Still to get all the columns fetched, we could do something like
print_r(array_keys($product->getData())); to print all the columns in the screen, for that model