Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the CMS page id of a particular page in Magento

Tags:

magento

In magento by using this code:

$currentPageId =$this->getRequest()->getParam('page_id');

we can get the current page id.

But how can I get the page id of a particular page?

For example, I have a page with URL key about-fruit-store.

I want to get its page id. How can I get it?

like image 814
Kichu Avatar asked Dec 27 '22 20:12

Kichu


1 Answers

Either

$model = Mage::getModel('cms/page')->load('about-fruit-store','identifier');
var_dump($model->getData());
var_dump($model->getPageId());

or

$model = Mage::getModel('cms/page')->getCollection()
->addFieldTofilter('identifier','about-fruit-store')
->getFirstItem();
var_dump($model->getData());
var_dump($model->getPageId());

should do it.

like image 66
Alan Storm Avatar answered Mar 25 '23 05:03

Alan Storm