Is there a way to update a eav custom attribute?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















My eav is:



$eavSetup->addAttribute(MagentoCatalogModelProduct::ENTITY,'bid_target',
[
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Bid Target',
'input' => 'text',
'class' => '',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'sort_order' => 0,
'group' => 'Informazioni Bid',
'apply_to' => ''
]
);


I get it with:



        $bid_prodotto = $prodotto->getResource()->getAttribute("bid_target")->getFrontend()->getValue($prodotto);


but i'm not able to update this value. Some tips? Thanks :)










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • From where you want to update, write more detail with specific M2 version.

    – Sohel Rana
    Mar 27 '17 at 5:10











  • From my custom Observer, when proceed-checkout trigger start

    – Paolovox
    Mar 27 '17 at 21:44











  • Example: $prodotto->updateAttribute("bid_target", $old + 1);

    – Paolovox
    Mar 27 '17 at 21:52


















1















My eav is:



$eavSetup->addAttribute(MagentoCatalogModelProduct::ENTITY,'bid_target',
[
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Bid Target',
'input' => 'text',
'class' => '',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'sort_order' => 0,
'group' => 'Informazioni Bid',
'apply_to' => ''
]
);


I get it with:



        $bid_prodotto = $prodotto->getResource()->getAttribute("bid_target")->getFrontend()->getValue($prodotto);


but i'm not able to update this value. Some tips? Thanks :)










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • From where you want to update, write more detail with specific M2 version.

    – Sohel Rana
    Mar 27 '17 at 5:10











  • From my custom Observer, when proceed-checkout trigger start

    – Paolovox
    Mar 27 '17 at 21:44











  • Example: $prodotto->updateAttribute("bid_target", $old + 1);

    – Paolovox
    Mar 27 '17 at 21:52














1












1








1


2






My eav is:



$eavSetup->addAttribute(MagentoCatalogModelProduct::ENTITY,'bid_target',
[
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Bid Target',
'input' => 'text',
'class' => '',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'sort_order' => 0,
'group' => 'Informazioni Bid',
'apply_to' => ''
]
);


I get it with:



        $bid_prodotto = $prodotto->getResource()->getAttribute("bid_target")->getFrontend()->getValue($prodotto);


but i'm not able to update this value. Some tips? Thanks :)










share|improve this question
















My eav is:



$eavSetup->addAttribute(MagentoCatalogModelProduct::ENTITY,'bid_target',
[
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Bid Target',
'input' => 'text',
'class' => '',
'source' => 'MagentoEavModelEntityAttributeSourceBoolean',
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'sort_order' => 0,
'group' => 'Informazioni Bid',
'apply_to' => ''
]
);


I get it with:



        $bid_prodotto = $prodotto->getResource()->getAttribute("bid_target")->getFrontend()->getValue($prodotto);


but i'm not able to update this value. Some tips? Thanks :)







magento2 eav-attributes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 5 '18 at 14:00









Shashank Kumrawat

1,3161343




1,3161343










asked Mar 26 '17 at 23:55









PaolovoxPaolovox

405




405





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • From where you want to update, write more detail with specific M2 version.

    – Sohel Rana
    Mar 27 '17 at 5:10











  • From my custom Observer, when proceed-checkout trigger start

    – Paolovox
    Mar 27 '17 at 21:44











  • Example: $prodotto->updateAttribute("bid_target", $old + 1);

    – Paolovox
    Mar 27 '17 at 21:52



















  • From where you want to update, write more detail with specific M2 version.

    – Sohel Rana
    Mar 27 '17 at 5:10











  • From my custom Observer, when proceed-checkout trigger start

    – Paolovox
    Mar 27 '17 at 21:44











  • Example: $prodotto->updateAttribute("bid_target", $old + 1);

    – Paolovox
    Mar 27 '17 at 21:52

















From where you want to update, write more detail with specific M2 version.

– Sohel Rana
Mar 27 '17 at 5:10





From where you want to update, write more detail with specific M2 version.

– Sohel Rana
Mar 27 '17 at 5:10













From my custom Observer, when proceed-checkout trigger start

– Paolovox
Mar 27 '17 at 21:44





From my custom Observer, when proceed-checkout trigger start

– Paolovox
Mar 27 '17 at 21:44













Example: $prodotto->updateAttribute("bid_target", $old + 1);

– Paolovox
Mar 27 '17 at 21:52





Example: $prodotto->updateAttribute("bid_target", $old + 1);

– Paolovox
Mar 27 '17 at 21:52










1 Answer
1






active

oldest

votes


















0














The EAV setup class vendor/magento/module-eav/Setup/EavSetup.php has an updateAttribute function :



/**
* Update Attribute data and Attribute additional data
*
* @param int|string $entityTypeId
* @param int|string $id
* @param string|array $field
* @param mixed $value
* @param int $sortOrder
* @return $this
*/
public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
$this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
$this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
return $this;
}


Use it in your module UpgradeData.php class.






share|improve this answer
























  • i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

    – Paolovox
    Mar 27 '17 at 21:49













  • @Paolovox please update your question with this information :)

    – Sander Mangel
    Oct 8 '18 at 7:42












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f166249%2fis-there-a-way-to-update-a-eav-custom-attribute%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









0














The EAV setup class vendor/magento/module-eav/Setup/EavSetup.php has an updateAttribute function :



/**
* Update Attribute data and Attribute additional data
*
* @param int|string $entityTypeId
* @param int|string $id
* @param string|array $field
* @param mixed $value
* @param int $sortOrder
* @return $this
*/
public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
$this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
$this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
return $this;
}


Use it in your module UpgradeData.php class.






share|improve this answer
























  • i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

    – Paolovox
    Mar 27 '17 at 21:49













  • @Paolovox please update your question with this information :)

    – Sander Mangel
    Oct 8 '18 at 7:42
















0














The EAV setup class vendor/magento/module-eav/Setup/EavSetup.php has an updateAttribute function :



/**
* Update Attribute data and Attribute additional data
*
* @param int|string $entityTypeId
* @param int|string $id
* @param string|array $field
* @param mixed $value
* @param int $sortOrder
* @return $this
*/
public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
$this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
$this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
return $this;
}


Use it in your module UpgradeData.php class.






share|improve this answer
























  • i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

    – Paolovox
    Mar 27 '17 at 21:49













  • @Paolovox please update your question with this information :)

    – Sander Mangel
    Oct 8 '18 at 7:42














0












0








0







The EAV setup class vendor/magento/module-eav/Setup/EavSetup.php has an updateAttribute function :



/**
* Update Attribute data and Attribute additional data
*
* @param int|string $entityTypeId
* @param int|string $id
* @param string|array $field
* @param mixed $value
* @param int $sortOrder
* @return $this
*/
public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
$this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
$this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
return $this;
}


Use it in your module UpgradeData.php class.






share|improve this answer













The EAV setup class vendor/magento/module-eav/Setup/EavSetup.php has an updateAttribute function :



/**
* Update Attribute data and Attribute additional data
*
* @param int|string $entityTypeId
* @param int|string $id
* @param string|array $field
* @param mixed $value
* @param int $sortOrder
* @return $this
*/
public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null)
{
$this->_updateAttribute($entityTypeId, $id, $field, $value, $sortOrder);
$this->_updateAttributeAdditionalData($entityTypeId, $id, $field, $value);
return $this;
}


Use it in your module UpgradeData.php class.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 '17 at 11:49









Franck GarnierFranck Garnier

2,096926




2,096926













  • i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

    – Paolovox
    Mar 27 '17 at 21:49













  • @Paolovox please update your question with this information :)

    – Sander Mangel
    Oct 8 '18 at 7:42



















  • i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

    – Paolovox
    Mar 27 '17 at 21:49













  • @Paolovox please update your question with this information :)

    – Sander Mangel
    Oct 8 '18 at 7:42

















i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

– Paolovox
Mar 27 '17 at 21:49







i mean a dynamic update, when an event is captured and not an static and fixed upgrade of an attribute. Thanks

– Paolovox
Mar 27 '17 at 21:49















@Paolovox please update your question with this information :)

– Sander Mangel
Oct 8 '18 at 7:42





@Paolovox please update your question with this information :)

– Sander Mangel
Oct 8 '18 at 7:42


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f166249%2fis-there-a-way-to-update-a-eav-custom-attribute%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto