M
M
Maybe_V2016-07-10 15:08:01
PHP
Maybe_V, 2016-07-10 15:08:01

How to properly get data from Magento model?

Problem with getting data from the Model (Magento Full Release - ver 1.9.2.4).
I get the model in the actioncontroller:

$news = Mage::getModel('dev_news/news')->getCollection();

Then to get the id I do:
foreach ($news as $item) {
            echo  $item->getId()
        }

Result:

Fatal error: Uncaught Error: Call to a member function order() on null in /home/vitaliy/hosts/module.dev/lib/Varien/Data/Collection/Db.php:506 Stack trace: #0

How to fix it? Can't find an answer.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
imdeveloper, 2016-07-14
@link_web

At you in other place an error to a campaign. Turn on developer mode and see where the error is

C
CodeKeeper, 2016-07-14
@CodeKeeper

var_dump($news);
and
what is issued?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question