简体   繁体   English

Magento 2管理网格中的“商店/网站”列-自定义模块`

[英]Store / Website Column in Magento 2 Admin Grid - Custom Module`

I have created a custom module in magento 2. I have two tables, first one is the main table and the other one is for the stores. 我在magento 2中创建了一个自定义模块。我有两个表,第一个是主表,另一个是用于商店。 The second table has the foreign key constraint of the first table's primary key and the store id column. 第二个表具有第一个表的主键和商店ID列的外键约束。 I have successfully created the gird and the form. 我已经成功创建了围栏和表格。 The only problem that I am having is that I am not able to load store ids in the grid. 我唯一的问题是我无法在网格中加载商店ID。 I am using ui_component approach, means, the grid is being rendered using xml. 我正在使用ui_component方法,这意味着使用xml渲染了网格。 If anyone requires code I can post it here but I believe it is pretty much understandable what I am looking for. 如果有人需要代码,我可以在这里发布,但我相信我在寻找什么是可以理解的。

Thanks in advanced. 提前致谢。

Check Magento\\Cms\\Block\\Adminhtml\\Page\\Grid 检查Magento \\ Cms \\ Block \\ Adminhtml \\ Page \\ Grid

 /**
 * Check is single store mode
 */
 if (!$this->_storeManager->isSingleStoreMode()) {
    $this->addColumn(
        'store_id',
         [
             'header' => __('Store View'),
             'index' => 'store_id',
             'type' => 'store',
             'store_all' => true,
             'store_view' => true,
             'sortable' => false,
             'filter_condition_callback' => [$this, '_filterStoreCondition']
            ]
        );
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM