Question

I've thought about magic methods(based on php)in Magento help developers work more easily.Especially, getter method is pretty useful to create own custom module.

As far as i know, get methods has some rules for existing

  1. use camelCase like getName() , getLastName()

  2. format like $this->getVariable

Actually, i've search on Google, i couldn't find the what extactly i have to write on gray part. I mean that i don't know what i write as variablemeans extactly.

is it from field name base on table ? or any other stuffs?

And i want to know the part what i checked as $order->getShippingdescription() , $product->getName(). is it called frontname?

Thank you so much!

Was it helpful?

Solution

If you have an object of a model class, your table column names are firstname, email_address, id. You can get this value following way:

$model->getFirstname(), 
$model->getEmailAddress() 

etc. that means every underscore remove and next first letter should be capital letter.

N.B: If any method name you can find that are unavailable in table column, it must be an model class custom method. Example: $order->getId() returns sales_flat_order table entity_id column.

If method is not an column name then it must be present in model class. e.g: $order->getPayment() return payment model object and its present in Mage_Sales_Model_Order class.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top