1

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!

3

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.

  • awww i perfectly got it. Then, if i know a name of model class and the column name of table that the model class use, am i able to use getter(or setter method) without any problem ? – 3CE Apr 6 '17 at 13:02
  • @3CE yes, you can. – Sohel Rana Apr 6 '17 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.