I found out how to get the first item from a collection:

$pageId = Mage::getModel('cms/page')->getCollection()
          ->addFieldToFilter('identifier', 'your name in the pages')

But now I have 3 IDs with the same name but different store views. How can I get these item-Ids? When I write that statement above without "getFirstItem()" and/or without "getId()" then Magento throws me an error.

2 Answers 2


Tipo,as you want using getFirstItem(),it only given 1 item,you need to remove this function and add getAllIds() function on this collection.

Full code:

$pageIds = Mage::getModel('cms/page')->getCollection()
          ->addFieldToFilter('identifier', 'your name in the pages')

getAllIds() give all ids in an array.

  • 1
    welcome ...:)....
    – Amit Bera
    Feb 10, 2015 at 10:13

Try getAllIds($limit = null, $offset = null)

That is a method for a collection object. So, once you get your collection, you would do something like this:


The $limit and $offset arguments are optional provide you with "paging" capabilities. E.g.

$collection->getAllIds(100,2500); // gets you 100 ids, starting from the 2500th of the collection (2500 - 2599)
  • Please add a little bit more of information and a complete example code snippet so beginners will understand your solution. Feb 9, 2015 at 9:21
  • I guess that's why Amit got the checkmark even though he just copied my answer an hour later. Oh well. Feb 11, 2015 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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