Today, we will discuss how we can get current CMS page id using code.
Below is an example.
Thank You.!
Below is an example.
protected $_page;
public function __construct(
...
\Magento\Cms\Model\Page $page,
...
array $data = []
) {
parent::__construct($context, $data);
...
$this->_page = $page;
...
}
if ($this->_page->getId()) {
$pageId = $this->_page->getId();
}
Thank You.!
Comments
Post a Comment