0

I am having a problem in the magento integration module, whenever I install the module from a company called CMsmart!

The error occurs when I try to create an integration in:

System-> Integration-> New Integration

The form for completing the new integration does not appear. Only the 'Save' buttons appear.

And if I click this button, the following error appears:

Warning: Undefined index: all_resources in /mnt/apache2/homolog.brasiltronic.com.br/vendor/magento/module-integration/Controller/Adminhtml/Integration.php on line 129

Is there any way I can fix this error? enter image description here

enter image description here

<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Integration\Controller\Adminhtml;

use Magento\Backend\App\Action;
use Magento\Integration\Api\OauthServiceInterface as IntegrationOauthService;

/**
 * Controller for integrations management.
 *
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
abstract class Integration extends Action
{
    /**
     * Authorization level of a basic admin session
     *
     * @see _isAllowed()
     */
    const ADMIN_RESOURCE = 'Magento_Integration::integrations';

    /** Param Key for extracting integration id from Request */
    const PARAM_INTEGRATION_ID = 'id';

    /** Reauthorize flag is used to distinguish activation from reauthorization */
    const PARAM_REAUTHORIZE = 'reauthorize';

    const REGISTRY_KEY_CURRENT_INTEGRATION = 'current_integration';

    /** Saved API form data session key */
    const REGISTRY_KEY_CURRENT_RESOURCE = 'current_resource';

    /**
     * @var \Magento\Framework\Registry
     */
    protected $_registry;

    /** @var \Psr\Log\LoggerInterface */
    protected $_logger;

    /** @var \Magento\Integration\Api\IntegrationServiceInterface */
    protected $_integrationService;

    /** @var \Magento\Integration\Api\OauthServiceInterface */
    protected $_oauthService;

    /** @var \Magento\Framework\Json\Helper\Data */
    protected $jsonHelper;

    /** @var \Magento\Integration\Helper\Data */
    protected $_integrationData;

    /** @var \Magento\Integration\Model\ResourceModel\Integration\Collection */
    protected $_integrationCollection;

    /**
     * @var \Magento\Framework\Escaper
     */
    protected $escaper;

    /**
     * @param \Magento\Backend\App\Action\Context $context
     * @param \Magento\Framework\Registry $registry
     * @param \Psr\Log\LoggerInterface $logger
     * @param \Magento\Integration\Api\IntegrationServiceInterface $integrationService
     * @param \Magento\Integration\Api\OauthServiceInterface $oauthService
     * @param \Magento\Framework\Json\Helper\Data $jsonHelper
     * @param \Magento\Integration\Helper\Data $integrationData
     * @param \Magento\Framework\Escaper $escaper
     * @param \Magento\Integration\Model\ResourceModel\Integration\Collection $integrationCollection
     */
    public function __construct(
        \Magento\Backend\App\Action\Context $context,
        \Magento\Framework\Registry $registry,
        \Psr\Log\LoggerInterface $logger,
        \Magento\Integration\Api\IntegrationServiceInterface $integrationService,
        \Magento\Integration\Api\OauthServiceInterface $oauthService,
        \Magento\Framework\Json\Helper\Data $jsonHelper,
        \Magento\Integration\Helper\Data $integrationData,
        \Magento\Framework\Escaper $escaper,
        \Magento\Integration\Model\ResourceModel\Integration\Collection $integrationCollection
    ) {
        parent::__construct($context);
        $this->_registry = $registry;
        $this->_logger = $logger;
        $this->_integrationService = $integrationService;
        $this->_oauthService = $oauthService;
        $this->jsonHelper = $jsonHelper;
        $this->_integrationData = $integrationData;
        $this->escaper = $escaper;
        $this->_integrationCollection = $integrationCollection;
        parent::__construct($context);
    }

    /**
     * Don't actually redirect if we've got AJAX request - return redirect URL instead.
     *
     * @param string $path
     * @param array $arguments
     * @return $this|\Magento\Backend\App\AbstractAction
     */
    protected function _redirect($path, $arguments = [])
    {
        if ($this->getRequest()->isXmlHttpRequest()) {
            $this->getResponse()->representJson(
                $this->jsonHelper->jsonEncode(['_redirect' => $this->getUrl($path, $arguments)])
            );
            return $this;
        } else {
            return parent::_redirect($path, $arguments);
        }
    }

    /**
     * Restore saved form resources
     *
     * @return void
     */
    protected function restoreResourceAndSaveToRegistry()
    {
        $restoredFormData = $this->_getSession()->getIntegrationData();
        if ($restoredFormData) {
            $resource = isset($restoredFormData['resource']) ? $restoredFormData['resource'] : [];
            $this->_registry->register(
                self::REGISTRY_KEY_CURRENT_RESOURCE,
                ['all_resources' => $restoredFormData['all_resources'], 'resource' => $resource]
            );
        }
    }
}
3
  • can you please add the code of that file? Commented Mar 15, 2018 at 20:50
  • I posted as an issue of the publication Commented Mar 15, 2018 at 20:57
  • $restoredFormData let me know what are you getting in this variable? in restoreResourceAndSaveToRegistry() function? Commented Mar 15, 2018 at 21:02

1 Answer 1

0

Always use arrays like this:

(...)
$someArray;

if(isset($someArray["all_resources"])) {
    /* now you can use that `all_resources` value... */
    foreach($someArray["all_resources"] as $resource) {
        $resource...;
    }
}

That is your problem in /mnt/apache2/homolog.brasiltronic.com.br/vendor/magento/module-integration/Controller/Adminhtml/Integration.php on line 129

You are trying to use array element with key all_resources but it's not exist.

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.