0

Below is my code to get CMS page title using CMS page url-key (identifer)

$formatIdentifier = "'{$_product->getUrlKey()}'";
$PageData = Mage::getModel('cms/page')->load($formatIdentifier,'identifier');
echo print_r($BuyingTitle->getData());exit;

The above code returns null, while the below code returns expected data.

$PageData = Mage::getModel('cms/page')->load('my-identifier','identifier');
echo print_r($BuyingTitle->getData());exit;

How can I pass my dynamic identifier using variable to get CMS page data ?

Thanks

6

You are adding quotes that are probably messing it up

$PageData = Mage::getModel('cms/page')->load($_product->getUrlKey(),'identifier');
echo print_r($BuyingTitle->getData());exit;

should work

  • Will this work ? $BuyingTitle = Mage::getModel('cms/page')->getResource()->getCmsPageTitleByIdentifier($_product->getUrlKey()); – Mark Mar 27 '14 at 12:08
  • I didn't test it but Mage::getResourceModel('cms/page')->getCmsPageTitleByIdentifier($_product‌​->getUrlKey()); should basically work – Sander Mangel Mar 27 '14 at 12:19
  • I do not know why my code did not work at first. I then tried for quotes.Thanks...:) – Mark Mar 27 '14 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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