Remove column from Order grid based on condition
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
4
down vote
favorite
I want to remove status
column from Magento admin panel order grid.
I use below code to remove the status
column in my sales_order_grid.xml
file. Reference
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>
</argument>
</column>
</columns>
</listing>
It removes status
column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration
section.
Is there any way I can add a condition on componentDisabled
, or any other way to achieve my requirements?
magento2 grid column
add a comment |Â
up vote
4
down vote
favorite
I want to remove status
column from Magento admin panel order grid.
I use below code to remove the status
column in my sales_order_grid.xml
file. Reference
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>
</argument>
</column>
</columns>
</listing>
It removes status
column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration
section.
Is there any way I can add a condition on componentDisabled
, or any other way to achieve my requirements?
magento2 grid column
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I want to remove status
column from Magento admin panel order grid.
I use below code to remove the status
column in my sales_order_grid.xml
file. Reference
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>
</argument>
</column>
</columns>
</listing>
It removes status
column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration
section.
Is there any way I can add a condition on componentDisabled
, or any other way to achieve my requirements?
magento2 grid column
I want to remove status
column from Magento admin panel order grid.
I use below code to remove the status
column in my sales_order_grid.xml
file. Reference
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>
</argument>
</column>
</columns>
</listing>
It removes status
column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration
section.
Is there any way I can add a condition on componentDisabled
, or any other way to achieve my requirements?
magento2 grid column
magento2 grid column
asked 1 hour ago


Jaimin Sutariya
9,05121751
9,05121751
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
It Might be helpful to you.
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
<settings>
<addField>true</addField>
<options class="MagentoStoreModelResourceModelWebsiteCollection"/>
<dataType>text</dataType>
<label translate="true">Websites</label>
</settings>
</column>
</columns>
</listing>
Websites.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCatalogUiComponentListingColumns;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoStoreModelStoreManagerInterface;
/**
* @api
* @since 100.0.2
*/
class Websites extends MagentoUiComponentListingColumnsColumn
/**
* Column name
*/
const NAME = 'websites';
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = ,
array $data =
)
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->storeManager = $storeManager;
/**
* @inheritdoc
* @deprecated 101.0.0
*/
public function prepareDataSource(array $dataSource)
$websiteNames = ;
foreach ($this->getData('options') as $website)
$websiteNames[$website->getWebsiteId()] = $website->getName();
if (isset($dataSource['data']['items']))
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item)
$websites = ;
foreach ($item[$fieldName] as $websiteId)
if (!isset($websiteNames[$websiteId]))
continue;
$websites = $websiteNames[$websiteId];
$item[$fieldName] = implode(', ', $websites);
return $dataSource;
/**
* Prepare component configuration
* @return void
*/
public function prepare()
parent::prepare();
if ($this->storeManager->isSingleStoreMode())
$this->_data['config']['componentDisabled'] = true;
It's defualt Magento which is used for to display website based on condition.
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
It Might be helpful to you.
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
<settings>
<addField>true</addField>
<options class="MagentoStoreModelResourceModelWebsiteCollection"/>
<dataType>text</dataType>
<label translate="true">Websites</label>
</settings>
</column>
</columns>
</listing>
Websites.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCatalogUiComponentListingColumns;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoStoreModelStoreManagerInterface;
/**
* @api
* @since 100.0.2
*/
class Websites extends MagentoUiComponentListingColumnsColumn
/**
* Column name
*/
const NAME = 'websites';
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = ,
array $data =
)
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->storeManager = $storeManager;
/**
* @inheritdoc
* @deprecated 101.0.0
*/
public function prepareDataSource(array $dataSource)
$websiteNames = ;
foreach ($this->getData('options') as $website)
$websiteNames[$website->getWebsiteId()] = $website->getName();
if (isset($dataSource['data']['items']))
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item)
$websites = ;
foreach ($item[$fieldName] as $websiteId)
if (!isset($websiteNames[$websiteId]))
continue;
$websites = $websiteNames[$websiteId];
$item[$fieldName] = implode(', ', $websites);
return $dataSource;
/**
* Prepare component configuration
* @return void
*/
public function prepare()
parent::prepare();
if ($this->storeManager->isSingleStoreMode())
$this->_data['config']['componentDisabled'] = true;
It's defualt Magento which is used for to display website based on condition.
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
It Might be helpful to you.
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
<settings>
<addField>true</addField>
<options class="MagentoStoreModelResourceModelWebsiteCollection"/>
<dataType>text</dataType>
<label translate="true">Websites</label>
</settings>
</column>
</columns>
</listing>
Websites.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCatalogUiComponentListingColumns;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoStoreModelStoreManagerInterface;
/**
* @api
* @since 100.0.2
*/
class Websites extends MagentoUiComponentListingColumnsColumn
/**
* Column name
*/
const NAME = 'websites';
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = ,
array $data =
)
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->storeManager = $storeManager;
/**
* @inheritdoc
* @deprecated 101.0.0
*/
public function prepareDataSource(array $dataSource)
$websiteNames = ;
foreach ($this->getData('options') as $website)
$websiteNames[$website->getWebsiteId()] = $website->getName();
if (isset($dataSource['data']['items']))
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item)
$websites = ;
foreach ($item[$fieldName] as $websiteId)
if (!isset($websiteNames[$websiteId]))
continue;
$websites = $websiteNames[$websiteId];
$item[$fieldName] = implode(', ', $websites);
return $dataSource;
/**
* Prepare component configuration
* @return void
*/
public function prepare()
parent::prepare();
if ($this->storeManager->isSingleStoreMode())
$this->_data['config']['componentDisabled'] = true;
It's defualt Magento which is used for to display website based on condition.
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
It Might be helpful to you.
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
<settings>
<addField>true</addField>
<options class="MagentoStoreModelResourceModelWebsiteCollection"/>
<dataType>text</dataType>
<label translate="true">Websites</label>
</settings>
</column>
</columns>
</listing>
Websites.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCatalogUiComponentListingColumns;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoStoreModelStoreManagerInterface;
/**
* @api
* @since 100.0.2
*/
class Websites extends MagentoUiComponentListingColumnsColumn
/**
* Column name
*/
const NAME = 'websites';
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = ,
array $data =
)
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->storeManager = $storeManager;
/**
* @inheritdoc
* @deprecated 101.0.0
*/
public function prepareDataSource(array $dataSource)
$websiteNames = ;
foreach ($this->getData('options') as $website)
$websiteNames[$website->getWebsiteId()] = $website->getName();
if (isset($dataSource['data']['items']))
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item)
$websites = ;
foreach ($item[$fieldName] as $websiteId)
if (!isset($websiteNames[$websiteId]))
continue;
$websites = $websiteNames[$websiteId];
$item[$fieldName] = implode(', ', $websites);
return $dataSource;
/**
* Prepare component configuration
* @return void
*/
public function prepare()
parent::prepare();
if ($this->storeManager->isSingleStoreMode())
$this->_data['config']['componentDisabled'] = true;
It's defualt Magento which is used for to display website based on condition.
It Might be helpful to you.
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
<settings>
<addField>true</addField>
<options class="MagentoStoreModelResourceModelWebsiteCollection"/>
<dataType>text</dataType>
<label translate="true">Websites</label>
</settings>
</column>
</columns>
</listing>
Websites.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MagentoCatalogUiComponentListingColumns;
use MagentoFrameworkViewElementUiComponentFactory;
use MagentoFrameworkViewElementUiComponentContextInterface;
use MagentoStoreModelStoreManagerInterface;
/**
* @api
* @since 100.0.2
*/
class Websites extends MagentoUiComponentListingColumnsColumn
/**
* Column name
*/
const NAME = 'websites';
/**
* Store manager
*
* @var StoreManagerInterface
*/
protected $storeManager;
/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
array $components = ,
array $data =
)
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->storeManager = $storeManager;
/**
* @inheritdoc
* @deprecated 101.0.0
*/
public function prepareDataSource(array $dataSource)
$websiteNames = ;
foreach ($this->getData('options') as $website)
$websiteNames[$website->getWebsiteId()] = $website->getName();
if (isset($dataSource['data']['items']))
$fieldName = $this->getData('name');
foreach ($dataSource['data']['items'] as & $item)
$websites = ;
foreach ($item[$fieldName] as $websiteId)
if (!isset($websiteNames[$websiteId]))
continue;
$websites = $websiteNames[$websiteId];
$item[$fieldName] = implode(', ', $websites);
return $dataSource;
/**
* Prepare component configuration
* @return void
*/
public function prepare()
parent::prepare();
if ($this->storeManager->isSingleStoreMode())
$this->_data['config']['componentDisabled'] = true;
It's defualt Magento which is used for to display website based on condition.
answered 1 hour ago


Dharmendra Jadav
1,258218
1,258218
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
add a comment |Â
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Thanks Dharmendra for the answer. I will try to implement it with my code.
– Jaimin Sutariya
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
Welcome bro anytime.
– Dharmendra Jadav
1 hour ago
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f242687%2fremove-column-from-order-grid-based-on-condition%23new-answer', 'question_page');
);
Post as a guest
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
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
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