简体   繁体   中英

How can I get the CMS page id of a particular page in 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM