문제

After load('id') function in model, we can get data by either model->getData('field_name') or model->getFieldName().

I know that both functions are provided by DataObject class but what I want to know is

  1. Is there any different between them ?
  2. What should I use ?
도움이 되었습니까?

해결책

Yes there is a bit of different, model->getFieldName() is a magic method so this will be public and in Magento 2 we can create plugins to manipulate output of public methods

(i.e) Lets assume

It is always advisable to use model->getFieldName() so can take advantage of plugins in Magento 2.

I Hope this explanation helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top