Magento 2 - Hide/Show custom EAV attribute after if conditionIs it possible to save attribute value per store in custom eav based model?Magento 2: How to add a custom attribute to the CMS PageCan virtual types be used as source models for EAV attributes?EAV default attribute value not taking effectCustom EAV model in magento 2Magento 2 add custom product attribute validation from install scriptHide EAV custom fieldGet attribute value of custom eav model in magento 2Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento 2 - get EAV value and display it on admin Grid
Reverse ColorFunction or ColorData
Installing Debian 10, upgrade to stable later?
How to deal with employer who keeps me at work after working hours
Where to draw the line between quantum mechanics theory and its interpretation(s)?
How to use awk to extract data from a file based on the content of another file?
What does のそ mean on this picture?
How is trade in services conducted under the WTO in the absence of the Doha conclusion?
Python 3 - simple temperature program version 1.3
Does Thanos's ship land in the middle of the battlefield in "Avengers: Endgame"?
Is there precedent or are there procedures for a US president refusing to concede to an electoral defeat?
Collision domain question
What detail can Hubble see on Mars?
Convert Numbers To Emoji Math
All of my Firefox add-ons been disabled suddenly, how can I re-enable them?
How can I obtain and work with a Platonic dodecahedron?
Debian 9 server no sshd in auth.log
How to say something covers all the view up to the horizon line?
Endgame puzzle: How to avoid stalemate and win?
How is Pauli's exclusion principle still valid in these cases?
Why increasing of the temperature of the objects like wood, paper etc. doesn't fire them?
The selling of the sheep
Can an earth elemental drag a tiny creature underground with Earth Glide?
Is throwing dice a stochastic or a deterministic process?
What do you call a painting painted on a wall?
Magento 2 - Hide/Show custom EAV attribute after if condition
Is it possible to save attribute value per store in custom eav based model?Magento 2: How to add a custom attribute to the CMS PageCan virtual types be used as source models for EAV attributes?EAV default attribute value not taking effectCustom EAV model in magento 2Magento 2 add custom product attribute validation from install scriptHide EAV custom fieldGet attribute value of custom eav model in magento 2Magento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento 2 - get EAV value and display it on admin Grid
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I created a new EAV attribute using this code :
'information',
[
'group' => 'Content',
'type' => 'int',
'default' => null,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false
]
PS: I added this attribute to the product form
this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?
magento2 eav eav-attributes
add a comment |
I created a new EAV attribute using this code :
'information',
[
'group' => 'Content',
'type' => 'int',
'default' => null,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false
]
PS: I added this attribute to the product form
this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?
magento2 eav eav-attributes
add a comment |
I created a new EAV attribute using this code :
'information',
[
'group' => 'Content',
'type' => 'int',
'default' => null,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false
]
PS: I added this attribute to the product form
this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?
magento2 eav eav-attributes
I created a new EAV attribute using this code :
'information',
[
'group' => 'Content',
'type' => 'int',
'default' => null,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => false
]
PS: I added this attribute to the product form
this attribute is by default hidden, but I want to visible it after a condition, is there any method to do that?
magento2 eav eav-attributes
magento2 eav eav-attributes
edited 2 days ago
sayou
asked May 2 at 15:28
sayousayou
1619
1619
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.
app/code/SR/MagentoCommunity/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
<plugin name="sr_attribute_visibility"
type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
$meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
// print $meta and check your custom attribute index.
return $meta;
[Update]
Suppose information is text attribute. Now modify following way:
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
if (isset($meta['product-details']['children']['container_information']))
$meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
return $meta;
PS: the attribute visibility should be by default: true (false don't work)
Thanks for your reply sir, That I need to change this['name']with['information']? name of my EAV attribute
– sayou
May 2 at 17:13
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I get this errorThe "componentType" configuration parameter is required for the "container_information" component
– sayou
May 2 at 17:16
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Check updated answer
– Sohel Rana
May 2 at 17:24
|
show 7 more comments
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%2f273244%2fmagento-2-hide-show-custom-eav-attribute-after-if-condition%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
You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.
app/code/SR/MagentoCommunity/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
<plugin name="sr_attribute_visibility"
type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
$meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
// print $meta and check your custom attribute index.
return $meta;
[Update]
Suppose information is text attribute. Now modify following way:
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
if (isset($meta['product-details']['children']['container_information']))
$meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
return $meta;
PS: the attribute visibility should be by default: true (false don't work)
Thanks for your reply sir, That I need to change this['name']with['information']? name of my EAV attribute
– sayou
May 2 at 17:13
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I get this errorThe "componentType" configuration parameter is required for the "container_information" component
– sayou
May 2 at 17:16
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Check updated answer
– Sohel Rana
May 2 at 17:24
|
show 7 more comments
You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.
app/code/SR/MagentoCommunity/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
<plugin name="sr_attribute_visibility"
type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
$meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
// print $meta and check your custom attribute index.
return $meta;
[Update]
Suppose information is text attribute. Now modify following way:
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
if (isset($meta['product-details']['children']['container_information']))
$meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
return $meta;
PS: the attribute visibility should be by default: true (false don't work)
Thanks for your reply sir, That I need to change this['name']with['information']? name of my EAV attribute
– sayou
May 2 at 17:13
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I get this errorThe "componentType" configuration parameter is required for the "container_information" component
– sayou
May 2 at 17:16
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Check updated answer
– Sohel Rana
May 2 at 17:24
|
show 7 more comments
You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.
app/code/SR/MagentoCommunity/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
<plugin name="sr_attribute_visibility"
type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
$meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
// print $meta and check your custom attribute index.
return $meta;
[Update]
Suppose information is text attribute. Now modify following way:
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
if (isset($meta['product-details']['children']['container_information']))
$meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
return $meta;
PS: the attribute visibility should be by default: true (false don't work)
You can easily do that using a plugin. Try following way to doing this. Following example will hide product name. For your custom attribute you need to modify plugin code.
app/code/SR/MagentoCommunity/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCatalogUiDataProviderProductFormModifierGeneral">
<plugin name="sr_attribute_visibility"
type="SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifierGeneral" sortOrder="1"/>
</type>
</config>
app/code/SR/MagentoCommunity/Plugin/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
$meta['product-details']['children']['container_name']['children']['name']['arguments']['data']['config']['visible'] = 0;
// print $meta and check your custom attribute index.
return $meta;
[Update]
Suppose information is text attribute. Now modify following way:
<?php
namespace SRMagentoCommunityPluginCatalogUiDataProviderProductFormModifier;
class General
public function afterModifyMeta(
MagentoCatalogUiDataProviderProductFormModifierGeneral $subject,
$meta
)
// add your condition
if (isset($meta['product-details']['children']['container_information']))
$meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
return $meta;
PS: the attribute visibility should be by default: true (false don't work)
edited 2 days ago
sayou
1619
1619
answered May 2 at 17:01
Sohel RanaSohel Rana
23.9k34461
23.9k34461
Thanks for your reply sir, That I need to change this['name']with['information']? name of my EAV attribute
– sayou
May 2 at 17:13
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I get this errorThe "componentType" configuration parameter is required for the "container_information" component
– sayou
May 2 at 17:16
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Check updated answer
– Sohel Rana
May 2 at 17:24
|
show 7 more comments
Thanks for your reply sir, That I need to change this['name']with['information']? name of my EAV attribute
– sayou
May 2 at 17:13
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I get this errorThe "componentType" configuration parameter is required for the "container_information" component
– sayou
May 2 at 17:16
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Check updated answer
– Sohel Rana
May 2 at 17:24
Thanks for your reply sir, That I need to change this
['name'] with ['information'] ? name of my EAV attribute– sayou
May 2 at 17:13
Thanks for your reply sir, That I need to change this
['name'] with ['information'] ? name of my EAV attribute– sayou
May 2 at 17:13
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I think you need to change container_name too. In your case should container_information.
– Sohel Rana
May 2 at 17:14
I get this error
The "componentType" configuration parameter is required for the "container_information" component– sayou
May 2 at 17:16
I get this error
The "componentType" configuration parameter is required for the "container_information" component– sayou
May 2 at 17:16
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Try using: $meta['product-details']['children']['container_information']['children']['information']['arguments']['data']['config']['visible'] = 0;
– Sohel Rana
May 2 at 17:22
Check updated answer
– Sohel Rana
May 2 at 17:24
Check updated answer
– Sohel Rana
May 2 at 17:24
|
show 7 more comments
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%2f273244%2fmagento-2-hide-show-custom-eav-attribute-after-if-condition%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