Magento models: how to get data from an array, not a database?

Typically, Magento models are “supported” by the MySQL database - this is where the data comes from and is stored. How can I get data from a standard PHP array? Is there any sample code anywhere? (I'm particularly interested in the “reading” aspect at the moment, but it would be helpful to know how to “write” too.)

+3
source share
2 answers

if you just keep track of the persistence of the model and see that it causes the conservation of your resource model

$this->_getResource()->beginTransaction();
    $dataCommited = false;
    try {
        $this->_beforeSave();
        if ($this->_dataSaveAllowed) {
            $this->_getResource()->save($this);
            $this->_afterSave();

this resource has a method

  $this->_getWriteAdapter();

from which you can call many sql methods

+1
source

magento _data . (fx. addData).

0

Source: https://habr.com/ru/post/1757084/


All Articles