【问题标题】:Magento 2 Custom Module Not Accessible In Other Users其他用户无法访问 Magento 2 自定义模块
【发布时间】:2017-04-23 15:18:27
【问题描述】:

我在 magento 2 管理员中有简单的网格列表自定义模块,但我无法在其他用户中访问它,然后是默认管理员,

这是我的文件

acl.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Spaarg_Tables::tables" title="tables" sortOrder="100"/>
 <!--AddMenuAcl-->
            </resource>
        </resources>
    </acl>
</config>

menu.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Spaarg. All rights reserved.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Backend/etc/menu.xsd">
    <menu>
        <add id="Spaarg_Tables::spaarg_tablesgrid_index" title="Tables" module="Spaarg_Tables"  sortOrder="20" dependsOnModule="Spaarg_Tables" action="tables/tablesgrid/index" resource="Spaarg_Tables::spaarg_tablesgrid_index"/>
<!--AddMenu-->
    </menu>
</config>

system.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd">
    <system>
        <section id="payment">
            <!-- payment-group -->
        </section>
        <section id="carriers" translate="label" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
            <!-- carrier-group -->
        </section>
        <section id="tables" translate="label" type="text" sortOrder="330" showInDefault="1" showInWebsite="1" showInStore="1">
            <!-- tables-group -->
        </section>
    </system>
</config>

这是我的控制器 Index.php

<?php
namespace Spaarg\Tables\Controller\Adminhtml\TablesGrid;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;


class Index extends Action
{
    /**
     * @var \Magento\Framework\View\Result\PageFactory
     */
    protected $resultPageFactory;

    /**
     * @var \Magento\Backend\Model\View\Result\Page
     */
    protected $resultPage;

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

    public function execute()
    {

        $this->resultPage = $this->resultPageFactory->create();  
        $this->resultPage->setActiveMenu('Spaarg_TablesGrid::tables');
        $this->resultPage ->getConfig()->getTitle()->set((__('TablesGrid')));
        return $this->resultPage;
    }

    protected function _isAllowed()
    {
      return $this->_authorization->isAllowed('Spaarg_TablesGrid::tables');
    }

}

它显示为我的模块签入用户角色, 我是 magento 的新手,如果有人能建议一种方法来处理这个问题,那就太好了。

【问题讨论】:

  • @ManthanDave 感谢您的快速回复,是的,他们是管理员用户。
  • 不,我不需要任何,我只需要在该用户、目录和我的自定义模块中访问两个模块,除此之外我有清除 magento 缓存并执行重新索引,但直到现在运气不好。
  • 是的,我完全按照你说的做了,当我选择“全部”作为资源访问时它会显示我的模块,但是当我通过复选框使用“自定义”选择时它不起作用。
  • 是的,因为如果你的模块依赖于另一个默认模块,那么它就不能工作,所以你需要注意你也可以访问依赖的模块

标签: php xml acl magento2


【解决方案1】:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                    <resource id="Magento_Backend::stores_settings">
                        <resource id="Magento_Config::config">                            
                            <resource id="Spaarg_Tables::tables" title="tables" sortOrder="100"/>
                        </resource>
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-30
相关资源
最近更新 更多