0

I installed magento2 2.2.10 version and installed custom modules. At begining it works finely after adding products , customers and place an order then it's not loading any admin grids(customers , sales , theme configuration , etc).

http://localhost/magento/admin/mui/index/render/key/384b4baacce8db392b425b6a0474d8572ba8651cb5a889f5be528b3546375ea6/?namespace=customer_listing&search=&filters%5Bplaceholder%5D=true&paging%5BpageSize%5D=20&paging%5Bcurrent%5D=1&sorting%5Bfield%5D=entity_id&sorting%5Bdirection%5D=asc&isAjax=true

This ajax call giving an error as below

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 2648 of the JSON data

Then i removed all my custom modules and run the following commands

php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex

But no success to get the grid working again. How can i debug what will be the error in this case? Which module causing error?

I removed all var/report logs and refresh the page in admin but there is no error logs at all.

In my index.php file i placed below code as well. No error coming.

ini_set('error_reporting', E_ERROR);
register_shutdown_function("fatal_handler");
function fatal_handler() {
$error = error_get_last();
echo("<pre>");
print_r($error);
}

In google when i searched got suggestion as ui_bookmark table needs to be cleared . I did that as well its still not loading any customers , pages , blocks , orders etc. Please help me on this..

I tried a fresh install and it has no issues... After added my custom modules got issue but i removed them all still issue is there. How can i trace it?

  • ANYBODY CAN HELP ME OUT PLEASE. MY WEBSITE WORKING CORRECTLY ONLY FOR ONE DAY. AFTER THAT IT IS GIVING ERROR ON ALL GRIDS. – Dinesh Nov 9 at 3:58
  • any help on how to debug ?? – Dinesh 2 days ago
1

You can trace the issues by creating your custom logger in your module. For example will share my module which I created for generating a custom log in my var folder.

After creating a basic module, create file:

/app/code/Magentoexample/Customlogger/Controller/Product/View.php

<?php

namespace Magentoexample\Customlogger\Controller\Product;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Psr\Log\LoggerInterface;

class View extends Action {

    /**
     * @var Psr\Log\LoggerInterface
     */
    private $logger;

    /**
     * @param Context $context
     * @param LoggerInterface $logger
     */
    public function __construct(
    Context $context, LoggerInterface $logger
    ) {
        $this->logger = $logger;
        parent::__construct($context);
    }

    /**
     * @return \Magento\Framework\Controller\Result\Json
     */
    public function execute() {
        $result = $this->resultJsonFactory->create();

        try {
            //your custom data handling logic....
        } catch (\Exception $e) {
            $this->logger->info($e->getMessage());
            return $result->setData(['success' => false, 'msg' => $e->getMessage()]);
        }
    }
}

/app/code/Magentoexample/Customlogger/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="customLogger" type="Magento\Framework\Logger\Monolog">
        <arguments>
            <argument name="handlers" xsi:type="array">
                <item name="debug" xsi:type="object">Magentoexample\Customlogger\Logger\Handler\Custom</item>
            </argument>
        </arguments>
    </virtualType>

    <type name="Magentoexample\Customlogger\Controller\Product\View">
        <arguments>
            <argument name="logger" xsi:type="object">customLogger</argument>
        </arguments>
    </type>
</config>

/app/code/Magentoexample/Customlogger/Logger/Handler/Custom.php

<?php

namespace Magentoexample\Customlogger\Logger\Handler;

use Magento\Framework\Logger\Handler\Base;
use Monolog\Logger;

class Custom extends Base {

    protected $fileName = '/var/log/customlogger/exception.log';
    protected $loggerType = Logger::DEBUG;

}

Hope this helps you! If any queries then please do let me know.

New contributor
Chandan Rai is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

you don't need to parse the returned data and use the following code-

json_data=data[0];
console.log(json_data[0]);

hope this will solve your issue

New contributor
Pramod is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • but in which file i can place this code?? i am getting error on pages , blocks , customers , orders . – Dinesh Nov 8 at 5:15
  • can you share the code..? – Pramod Nov 8 at 9:36
  • which code i need to share? – Dinesh Nov 8 at 9:47

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.