public function executeForJson()

in Controller/Adminhtml/Ajax/Fbfeedpush.php [28:58]


    public function executeForJson()
    {
        $response = [];
        $external_business_id = $this->_fbeHelper->getConfigValue('fbe/external/id');
        $this->_fbeHelper->log("Existing external business id --- ". $external_business_id);
        if ($external_business_id) {
            $response['success'] = false;
            $response['message'] = 'One time feed push is completed at the time of setup';
            return $response;
        }
        try {
            /* even the rest code failed, we should store external business id and catalog id,
            because user can push feed sync button in configuration*/
            $access_token = $this->getRequest()->getParam('accessToken');
            $external_business_id = $this->getRequest()->getParam('externalBusinessId');
            $this->saveExternalBusinessId($external_business_id);
            $catalog_id = $this->getRequest()->getParam('catalogId');
            $this->saveCatalogId($catalog_id);
            if ($access_token) {
                $feed_push_response = $this->batchApi->generateProductRequestData($access_token);
                $response['success'] = true;
                $response['feed_push_response'] = $feed_push_response;
                return $response;
            }
        } catch (\Exception $e) {
            $response['success'] = false;
            $response['message'] = $e->getMessage();
            $this->_fbeHelper->logException($e);
            return $response;
        }
    }