Magento, magic getters v getData

I have been using magento for a while and always cannot decide between using magic getter and getData ()

Can someone explain the main difference besides the minor overhead (and it should be very small).

I mean:

  • Future proof of code (I think magento 2 will not use a magic getter)
  • Stylistically
  • Performance
  • Sustainability
  • Any other reasons for using 1 over another

There is no clear way to switch to base code, as it uses a mixture of both

+5
source share
3 answers

, - getData($key). , . , getData getData(). , -. -, , , ( , getName() , ). getData().

+3

, , , , , .

, CamelCase under_score .

getData() .

, :

getAttributeName(), getData ('attribute_name')

- , , getAttributeName(), . , getData(), ​​ , , .

+9

, getData . 2 :

1) , - _underscore Varien_Object ( ).

2) getData , "" , , getData, , .

Varien_Object, :

$firstObject->getData('second_object')->getData('third_object')->getData('some_string');

:

$firstObject->getData('second_object/third_object/some_string');
0
source

All Articles