How to add storeview switcher in custom admin grid which created using ui component in magento2.2.5?
How to add storeview code in admin grid which created using ui component.
magento2 multistore uicomponent
add a comment |
How to add storeview code in admin grid which created using ui component.
magento2 multistore uicomponent
add a comment |
How to add storeview code in admin grid which created using ui component.
magento2 multistore uicomponent
How to add storeview code in admin grid which created using ui component.
magento2 multistore uicomponent
magento2 multistore uicomponent
asked Dec 7 '18 at 5:04
Rutvee SojitraRutvee Sojitra
1,4661121
1,4661121
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Update your layout as below. (File: MyVendor/MyModule/view/adminhtml/layout/mymodule_myproduct_grid.xml )
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="page.main.actions">
<block class="MagentoBackendBlockStoreSwitcher" name="adminhtml.report.grid.store_switcher" as="store_switcher">
<arguments>
<argument name="use_confirm" xsi:type="string">0</argument>
<argument name="switch_websites" xsi:type="string">0</argument>
<argument name="switch_store_groups" xsi:type="string">0</argument>
<argument name="switch_store_views" xsi:type="string">1</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="content">
<uiComponent name="my_product_listing"/>
</referenceContainer>
</body>
</page>
To filter products you need to change the UI component for the Bookmark
.
Create a UI component class as (File: MyVendor/MyModule/Component/Bookmark.php )
:
namespace MyVendorMyModuleComponent;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoUiApiBookmarkManagementInterface;
use MagentoUiApiBookmarkRepositoryInterface;
class Bookmark extends MagentoUiComponentBookmark
{
public function __construct(
ContextInterface $context,
MyVendorMyModuleApiProfileRepositoryInterface $profile,
BookmarkRepositoryInterface $bookmarkRepository,
BookmarkManagementInterface $bookmarkManagement,
array $components = ,
array $data =
) {
parent::__construct($context, $bookmarkRepository, $bookmarkManagement, $components, $data);
$this->profile = $profile;
}
/**
* Register component
*
* @return void
*/
public function prepare()
{
$namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
$config = ;
if (!empty($namespace)) {
$storeId = $this->getContext()->getRequestParam('store');
if (empty($storeId)) {
$storeId = $this->getContext()->getFilterParam('store_id');
}
$bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
/** @var MagentoUiApiDataBookmarkInterface $bookmark */
foreach ($bookmarks->getItems() as $bookmark) {
if ($bookmark->isCurrent()) {
$config['activeIndex'] = $bookmark->getIdentifier();
}
$config = array_merge_recursive($config, $bookmark->getConfig());
if (!empty($storeId)) {
$config['current']['filters']['applied']['store_id'] = $storeId;
}
}
}
$this->setData('config', array_replace_recursive($config, $this->getConfiguration($this)));
parent::prepare();
$jsConfig = $this->getConfiguration($this);
$this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
}
}
Add the Bookmark
UI component in your UI grid xml (File: MyVendor/MyModule/view/adminhtml/ui_component/my_product_listing.xml )
:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sticky" xsi:type="boolean">true</item>
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<bookmark name="bookmarks" class="MyVendorMyModuleComponentBookmark">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item>
<item name="storageConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/>
<item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/>
<item name="namespace" xsi:type="string">my_product_listing</item>
</item>
</item>
</argument>
</bookmark>
<columnsControls name="columns_controls"/>
<filters name="listing_filters" />
<paging name="listing_paging"/>
</listingToolbar>
</listing>
Replace: MyVendorMyModule
and my_product_listing
with your namespace.
Also there is another way of add the store selector in the grid i.e via filters same as catalog product grid.
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
1
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f252738%2fhow-to-add-storeview-switcher-in-custom-admin-grid-which-created-using-ui-compon%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update your layout as below. (File: MyVendor/MyModule/view/adminhtml/layout/mymodule_myproduct_grid.xml )
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="page.main.actions">
<block class="MagentoBackendBlockStoreSwitcher" name="adminhtml.report.grid.store_switcher" as="store_switcher">
<arguments>
<argument name="use_confirm" xsi:type="string">0</argument>
<argument name="switch_websites" xsi:type="string">0</argument>
<argument name="switch_store_groups" xsi:type="string">0</argument>
<argument name="switch_store_views" xsi:type="string">1</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="content">
<uiComponent name="my_product_listing"/>
</referenceContainer>
</body>
</page>
To filter products you need to change the UI component for the Bookmark
.
Create a UI component class as (File: MyVendor/MyModule/Component/Bookmark.php )
:
namespace MyVendorMyModuleComponent;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoUiApiBookmarkManagementInterface;
use MagentoUiApiBookmarkRepositoryInterface;
class Bookmark extends MagentoUiComponentBookmark
{
public function __construct(
ContextInterface $context,
MyVendorMyModuleApiProfileRepositoryInterface $profile,
BookmarkRepositoryInterface $bookmarkRepository,
BookmarkManagementInterface $bookmarkManagement,
array $components = ,
array $data =
) {
parent::__construct($context, $bookmarkRepository, $bookmarkManagement, $components, $data);
$this->profile = $profile;
}
/**
* Register component
*
* @return void
*/
public function prepare()
{
$namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
$config = ;
if (!empty($namespace)) {
$storeId = $this->getContext()->getRequestParam('store');
if (empty($storeId)) {
$storeId = $this->getContext()->getFilterParam('store_id');
}
$bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
/** @var MagentoUiApiDataBookmarkInterface $bookmark */
foreach ($bookmarks->getItems() as $bookmark) {
if ($bookmark->isCurrent()) {
$config['activeIndex'] = $bookmark->getIdentifier();
}
$config = array_merge_recursive($config, $bookmark->getConfig());
if (!empty($storeId)) {
$config['current']['filters']['applied']['store_id'] = $storeId;
}
}
}
$this->setData('config', array_replace_recursive($config, $this->getConfiguration($this)));
parent::prepare();
$jsConfig = $this->getConfiguration($this);
$this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
}
}
Add the Bookmark
UI component in your UI grid xml (File: MyVendor/MyModule/view/adminhtml/ui_component/my_product_listing.xml )
:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sticky" xsi:type="boolean">true</item>
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<bookmark name="bookmarks" class="MyVendorMyModuleComponentBookmark">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item>
<item name="storageConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/>
<item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/>
<item name="namespace" xsi:type="string">my_product_listing</item>
</item>
</item>
</argument>
</bookmark>
<columnsControls name="columns_controls"/>
<filters name="listing_filters" />
<paging name="listing_paging"/>
</listingToolbar>
</listing>
Replace: MyVendorMyModule
and my_product_listing
with your namespace.
Also there is another way of add the store selector in the grid i.e via filters same as catalog product grid.
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
1
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
add a comment |
Update your layout as below. (File: MyVendor/MyModule/view/adminhtml/layout/mymodule_myproduct_grid.xml )
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="page.main.actions">
<block class="MagentoBackendBlockStoreSwitcher" name="adminhtml.report.grid.store_switcher" as="store_switcher">
<arguments>
<argument name="use_confirm" xsi:type="string">0</argument>
<argument name="switch_websites" xsi:type="string">0</argument>
<argument name="switch_store_groups" xsi:type="string">0</argument>
<argument name="switch_store_views" xsi:type="string">1</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="content">
<uiComponent name="my_product_listing"/>
</referenceContainer>
</body>
</page>
To filter products you need to change the UI component for the Bookmark
.
Create a UI component class as (File: MyVendor/MyModule/Component/Bookmark.php )
:
namespace MyVendorMyModuleComponent;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoUiApiBookmarkManagementInterface;
use MagentoUiApiBookmarkRepositoryInterface;
class Bookmark extends MagentoUiComponentBookmark
{
public function __construct(
ContextInterface $context,
MyVendorMyModuleApiProfileRepositoryInterface $profile,
BookmarkRepositoryInterface $bookmarkRepository,
BookmarkManagementInterface $bookmarkManagement,
array $components = ,
array $data =
) {
parent::__construct($context, $bookmarkRepository, $bookmarkManagement, $components, $data);
$this->profile = $profile;
}
/**
* Register component
*
* @return void
*/
public function prepare()
{
$namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
$config = ;
if (!empty($namespace)) {
$storeId = $this->getContext()->getRequestParam('store');
if (empty($storeId)) {
$storeId = $this->getContext()->getFilterParam('store_id');
}
$bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
/** @var MagentoUiApiDataBookmarkInterface $bookmark */
foreach ($bookmarks->getItems() as $bookmark) {
if ($bookmark->isCurrent()) {
$config['activeIndex'] = $bookmark->getIdentifier();
}
$config = array_merge_recursive($config, $bookmark->getConfig());
if (!empty($storeId)) {
$config['current']['filters']['applied']['store_id'] = $storeId;
}
}
}
$this->setData('config', array_replace_recursive($config, $this->getConfiguration($this)));
parent::prepare();
$jsConfig = $this->getConfiguration($this);
$this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
}
}
Add the Bookmark
UI component in your UI grid xml (File: MyVendor/MyModule/view/adminhtml/ui_component/my_product_listing.xml )
:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sticky" xsi:type="boolean">true</item>
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<bookmark name="bookmarks" class="MyVendorMyModuleComponentBookmark">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item>
<item name="storageConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/>
<item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/>
<item name="namespace" xsi:type="string">my_product_listing</item>
</item>
</item>
</argument>
</bookmark>
<columnsControls name="columns_controls"/>
<filters name="listing_filters" />
<paging name="listing_paging"/>
</listingToolbar>
</listing>
Replace: MyVendorMyModule
and my_product_listing
with your namespace.
Also there is another way of add the store selector in the grid i.e via filters same as catalog product grid.
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
1
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
add a comment |
Update your layout as below. (File: MyVendor/MyModule/view/adminhtml/layout/mymodule_myproduct_grid.xml )
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="page.main.actions">
<block class="MagentoBackendBlockStoreSwitcher" name="adminhtml.report.grid.store_switcher" as="store_switcher">
<arguments>
<argument name="use_confirm" xsi:type="string">0</argument>
<argument name="switch_websites" xsi:type="string">0</argument>
<argument name="switch_store_groups" xsi:type="string">0</argument>
<argument name="switch_store_views" xsi:type="string">1</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="content">
<uiComponent name="my_product_listing"/>
</referenceContainer>
</body>
</page>
To filter products you need to change the UI component for the Bookmark
.
Create a UI component class as (File: MyVendor/MyModule/Component/Bookmark.php )
:
namespace MyVendorMyModuleComponent;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoUiApiBookmarkManagementInterface;
use MagentoUiApiBookmarkRepositoryInterface;
class Bookmark extends MagentoUiComponentBookmark
{
public function __construct(
ContextInterface $context,
MyVendorMyModuleApiProfileRepositoryInterface $profile,
BookmarkRepositoryInterface $bookmarkRepository,
BookmarkManagementInterface $bookmarkManagement,
array $components = ,
array $data =
) {
parent::__construct($context, $bookmarkRepository, $bookmarkManagement, $components, $data);
$this->profile = $profile;
}
/**
* Register component
*
* @return void
*/
public function prepare()
{
$namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
$config = ;
if (!empty($namespace)) {
$storeId = $this->getContext()->getRequestParam('store');
if (empty($storeId)) {
$storeId = $this->getContext()->getFilterParam('store_id');
}
$bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
/** @var MagentoUiApiDataBookmarkInterface $bookmark */
foreach ($bookmarks->getItems() as $bookmark) {
if ($bookmark->isCurrent()) {
$config['activeIndex'] = $bookmark->getIdentifier();
}
$config = array_merge_recursive($config, $bookmark->getConfig());
if (!empty($storeId)) {
$config['current']['filters']['applied']['store_id'] = $storeId;
}
}
}
$this->setData('config', array_replace_recursive($config, $this->getConfiguration($this)));
parent::prepare();
$jsConfig = $this->getConfiguration($this);
$this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
}
}
Add the Bookmark
UI component in your UI grid xml (File: MyVendor/MyModule/view/adminhtml/ui_component/my_product_listing.xml )
:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sticky" xsi:type="boolean">true</item>
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<bookmark name="bookmarks" class="MyVendorMyModuleComponentBookmark">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item>
<item name="storageConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/>
<item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/>
<item name="namespace" xsi:type="string">my_product_listing</item>
</item>
</item>
</argument>
</bookmark>
<columnsControls name="columns_controls"/>
<filters name="listing_filters" />
<paging name="listing_paging"/>
</listingToolbar>
</listing>
Replace: MyVendorMyModule
and my_product_listing
with your namespace.
Also there is another way of add the store selector in the grid i.e via filters same as catalog product grid.
Update your layout as below. (File: MyVendor/MyModule/view/adminhtml/layout/mymodule_myproduct_grid.xml )
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="page.main.actions">
<block class="MagentoBackendBlockStoreSwitcher" name="adminhtml.report.grid.store_switcher" as="store_switcher">
<arguments>
<argument name="use_confirm" xsi:type="string">0</argument>
<argument name="switch_websites" xsi:type="string">0</argument>
<argument name="switch_store_groups" xsi:type="string">0</argument>
<argument name="switch_store_views" xsi:type="string">1</argument>
</arguments>
</block>
</referenceContainer>
<referenceContainer name="content">
<uiComponent name="my_product_listing"/>
</referenceContainer>
</body>
</page>
To filter products you need to change the UI component for the Bookmark
.
Create a UI component class as (File: MyVendor/MyModule/Component/Bookmark.php )
:
namespace MyVendorMyModuleComponent;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoUiApiBookmarkManagementInterface;
use MagentoUiApiBookmarkRepositoryInterface;
class Bookmark extends MagentoUiComponentBookmark
{
public function __construct(
ContextInterface $context,
MyVendorMyModuleApiProfileRepositoryInterface $profile,
BookmarkRepositoryInterface $bookmarkRepository,
BookmarkManagementInterface $bookmarkManagement,
array $components = ,
array $data =
) {
parent::__construct($context, $bookmarkRepository, $bookmarkManagement, $components, $data);
$this->profile = $profile;
}
/**
* Register component
*
* @return void
*/
public function prepare()
{
$namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
$config = ;
if (!empty($namespace)) {
$storeId = $this->getContext()->getRequestParam('store');
if (empty($storeId)) {
$storeId = $this->getContext()->getFilterParam('store_id');
}
$bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
/** @var MagentoUiApiDataBookmarkInterface $bookmark */
foreach ($bookmarks->getItems() as $bookmark) {
if ($bookmark->isCurrent()) {
$config['activeIndex'] = $bookmark->getIdentifier();
}
$config = array_merge_recursive($config, $bookmark->getConfig());
if (!empty($storeId)) {
$config['current']['filters']['applied']['store_id'] = $storeId;
}
}
}
$this->setData('config', array_replace_recursive($config, $this->getConfiguration($this)));
parent::prepare();
$jsConfig = $this->getConfiguration($this);
$this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
}
}
Add the Bookmark
UI component in your UI grid xml (File: MyVendor/MyModule/view/adminhtml/ui_component/my_product_listing.xml )
:
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="sticky" xsi:type="boolean">true</item>
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<bookmark name="bookmarks" class="MyVendorMyModuleComponentBookmark">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/controls/bookmarks/bookmarks</item>
<item name="storageConfig" xsi:type="array">
<item name="saveUrl" xsi:type="url" path="mui/bookmark/save"/>
<item name="deleteUrl" xsi:type="url" path="mui/bookmark/delete"/>
<item name="namespace" xsi:type="string">my_product_listing</item>
</item>
</item>
</argument>
</bookmark>
<columnsControls name="columns_controls"/>
<filters name="listing_filters" />
<paging name="listing_paging"/>
</listingToolbar>
</listing>
Replace: MyVendorMyModule
and my_product_listing
with your namespace.
Also there is another way of add the store selector in the grid i.e via filters same as catalog product grid.
edited 4 mins ago
answered Dec 7 '18 at 6:39
Milind SinghMilind Singh
648215
648215
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
1
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
add a comment |
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
1
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
Also, Do you want to filter products on the basis of the selected store? Because that's another thing to be done.
– Milind Singh
Dec 7 '18 at 6:43
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
yes i want to do
– Rutvee Sojitra
Dec 7 '18 at 6:44
1
1
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
@RutveeSojitra I have updated the code. hope it helps
– Milind Singh
Dec 7 '18 at 6:55
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @MilindSingh. Can you please update file path in your answer ? It will be helpful for me.
– Dharmik Ponda
34 mins ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
Hi @DharmikPonda I have updated the paths. Hope it helps.
– Milind Singh
1 min ago
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f252738%2fhow-to-add-storeview-switcher-in-custom-admin-grid-which-created-using-ui-compon%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown