4

I have problem with creating new page from backend it shows me this message: Something went wrong while saving the page.

I can edit and save the page but I can't create the new page. any idea??

3
  • 1
    Check logs on var/logs for any exceptions or more info related to this issue Mar 30, 2017 at 7:37
  • Nothing in it related to cms page
    – Rajan Soni
    Mar 30, 2017 at 11:38
  • Can you check console logs? Mar 30, 2017 at 11:39

3 Answers 3

4

Yes I got the solution for that:

I have installed MageWorx SeoBase extension that extension adds two fields in the cms_page table: 1. meta_robots and 2. mageworx_hreflang_identifier

but that field does not show on the content > page and both fields are set as nullable = false;

that's why the page was not saving I just go the database, open the cms_page table and just select true in a null field and now its working.

3

The best idea to get the solution is try and catch which was introduced in PHP 5 then you only need to check exception message.

try{
  //Your code logic
}
catch (\Exception $e) {
  //First find the message and then echo $e message.
  echo $e->getMessage(); die('errorMessage'); 
  $this->messageManager->addException($e, __('Something went wrong while saving the page.'));
}
1
  • Hi @manishgoswami can you please let me know I face below issue when creating a configurable product on version 2.1.0 ------ exception 'Zend_Db_Select_Exception' with message 'You cannot define a correlation name 'oi' more than once'
    – Rajan Soni
    May 12, 2018 at 10:25
1

Magento\Cms\Controller\Adminhtml\Page\InlineEdit

public function execute()
{
    /** @var \Magento\Framework\Controller\Result\Json $resultJson */
    $resultJson = $this->jsonFactory->create();
    $error = false;
    $messages = [];

    $postItems = $this->getRequest()->getParam('items', []);
    if (!($this->getRequest()->getParam('isAjax') && count($postItems))) {
        return $resultJson->setData([
            'messages' => [__('Please correct the data sent.')],
            'error' => true,
        ]);
    }

    foreach (array_keys($postItems) as $pageId) {
        /** @var \Magento\Cms\Model\Page $page */
        $page = $this->pageRepository->getById($pageId);
        try {
            /*Magento issue fix since it passes Invalid date for custom_theme_from*/
            $dataset = $postItems[$pageId];
            if(isset($dataset['custom_theme_from']) && $dataset['custom_theme_from']=="Invalid date"){
                unset($dataset['custom_theme_from']);
            }

            if(isset($dataset['custom_theme_to']) && $dataset['custom_theme_to']=="Invalid date"){
                unset($dataset['custom_theme_to']);
            }

            $postItems[$pageId] = $dataset;

            $pageData = $this->filterPost($postItems[$pageId]);
            $this->validatePost($pageData, $page, $error, $messages);
            $extendedPageData = $page->getData();
            $this->setCmsPageData($page, $extendedPageData, $pageData);
            $this->pageRepository->save($page);
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
            $messages[] = $this->getErrorWithPageId($page, $e->getMessage());
            $error = true;
        } catch (\RuntimeException $e) {
            $messages[] = $this->getErrorWithPageId($page, $e->getMessage());
            $error = true;
        } catch (\Exception $e) {
            $messages[] = $this->getErrorWithPageId(
                $page,
                __('Something went wrong while saving the page.')
            );
            $error = true;
        }
    }

    return $resultJson->setData([
        'messages' => $messages,
        'error' => $error
    ]);
}

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.