How to set data for custom attribute in foreach loop Magento 2?How can i set a name or custom attribute for a...

Does music exist in Panem? And if so, what kinds of music?

Non-Italian European mafias in USA?

How do ISS astronauts "get their stripes"?

Second-rate spelling

It took me a lot of time to make this, pls like. (YouTube Comments #1)

How do I construct an nxn matrix?

Which aircraft had such a luxurious-looking navigator's station?

Is there a ternary operator in math

How can atoms be electrically neutral when there is a difference in the positions of the charges?

Pure Functions: Does "No Side Effects" Imply "Always Same Output, Given Same Input"?

How to count words in a line

How to count occurrences of Friday 13th

When was drinking water recognized as crucial in marathon running?

Must a tritone substitution use a dominant seventh chord?

What is the difference between ashamed and shamed?

chrony vs. systemd-timesyncd – What are the differences and use cases as NTP clients?

Is the set of paths between any two points moving only in units on the plane countable or uncountable?

How to properly claim credit for peer review?

Is there a German word for “analytics”?

Can you benefit from a Hammer of Thunderbolts’s Strength increase by holding it with something else than your hands?

Can you use a beast's innate abilities while polymorphed?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Understanding Kramnik's play in game 1 of Candidates 2018

Difference between 小吃 and 零食



How to set data for custom attribute in foreach loop Magento 2?


How can i set a name or custom attribute for a specific storeview through REST API?How to update custom customer attribute default value magento 2.XMedia image attribute bugged in frontendMagento 2 Category custom attribute display standard wayMagento 2 : How can I display an attribute on the category page?Magento 2 - Override title.phtml with custom attribute valueSet custom value from query result for product attribute in magento 2 admin panelSetting custom product attribute value in magento 2Magento 2 How to upgrade existing custom customer address attribute?Convert(re-write) array_filter code into foreach loop













0















I need to set data for custom attribute in foreach loop.My code is here. which is in foreach loop.



 echo "<b>".$attribute."</b>"."<br/>";                          
echo $value."<br/>";


$attrs = $product->getResource()->getAttribute($attribute); //warrant
$veYstorage = $value;
$avisstorage = $attrs->getSource()->getOptionId($veYstorage); //name in Default Store View
$product->setData($attribute, $avisstorage);


Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0










share|improve this question

























  • have you added $product->save(); in loop ?

    – Mohit chauhan
    10 mins ago











  • Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0...Actualy i am getting above error.

    – Anees
    5 mins ago











  • Do you have somewhere $product->save(); in yor code after setting the attributes? If not you should add that. If yes what happens exactly?

    – HelgeB
    4 mins ago













  • yes i have $product->save(); in end and product is saving but above errors come on attribute set data.

    – Anees
    2 mins ago
















0















I need to set data for custom attribute in foreach loop.My code is here. which is in foreach loop.



 echo "<b>".$attribute."</b>"."<br/>";                          
echo $value."<br/>";


$attrs = $product->getResource()->getAttribute($attribute); //warrant
$veYstorage = $value;
$avisstorage = $attrs->getSource()->getOptionId($veYstorage); //name in Default Store View
$product->setData($attribute, $avisstorage);


Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0










share|improve this question

























  • have you added $product->save(); in loop ?

    – Mohit chauhan
    10 mins ago











  • Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0...Actualy i am getting above error.

    – Anees
    5 mins ago











  • Do you have somewhere $product->save(); in yor code after setting the attributes? If not you should add that. If yes what happens exactly?

    – HelgeB
    4 mins ago













  • yes i have $product->save(); in end and product is saving but above errors come on attribute set data.

    – Anees
    2 mins ago














0












0








0








I need to set data for custom attribute in foreach loop.My code is here. which is in foreach loop.



 echo "<b>".$attribute."</b>"."<br/>";                          
echo $value."<br/>";


$attrs = $product->getResource()->getAttribute($attribute); //warrant
$veYstorage = $value;
$avisstorage = $attrs->getSource()->getOptionId($veYstorage); //name in Default Store View
$product->setData($attribute, $avisstorage);


Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0










share|improve this question
















I need to set data for custom attribute in foreach loop.My code is here. which is in foreach loop.



 echo "<b>".$attribute."</b>"."<br/>";                          
echo $value."<br/>";


$attrs = $product->getResource()->getAttribute($attribute); //warrant
$veYstorage = $value;
$avisstorage = $attrs->getSource()->getOptionId($veYstorage); //name in Default Store View
$product->setData($attribute, $avisstorage);


Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0







magento2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 mins ago







Anees

















asked 23 mins ago









AneesAnees

13811




13811













  • have you added $product->save(); in loop ?

    – Mohit chauhan
    10 mins ago











  • Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0...Actualy i am getting above error.

    – Anees
    5 mins ago











  • Do you have somewhere $product->save(); in yor code after setting the attributes? If not you should add that. If yes what happens exactly?

    – HelgeB
    4 mins ago













  • yes i have $product->save(); in end and product is saving but above errors come on attribute set data.

    – Anees
    2 mins ago



















  • have you added $product->save(); in loop ?

    – Mohit chauhan
    10 mins ago











  • Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0...Actualy i am getting above error.

    – Anees
    5 mins ago











  • Do you have somewhere $product->save(); in yor code after setting the attributes? If not you should add that. If yes what happens exactly?

    – HelgeB
    4 mins ago













  • yes i have $product->save(); in end and product is saving but above errors come on attribute set data.

    – Anees
    2 mins ago

















have you added $product->save(); in loop ?

– Mohit chauhan
10 mins ago





have you added $product->save(); in loop ?

– Mohit chauhan
10 mins ago













Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0...Actualy i am getting above error.

– Anees
5 mins ago





Fatal error: Uncaught Error: Call to a member function getSource() on boolean in E:xampp7.0...Actualy i am getting above error.

– Anees
5 mins ago













Do you have somewhere $product->save(); in yor code after setting the attributes? If not you should add that. If yes what happens exactly?

– HelgeB
4 mins ago







Do you have somewhere $product->save(); in yor code after setting the attributes? If not you should add that. If yes what happens exactly?

– HelgeB
4 mins ago















yes i have $product->save(); in end and product is saving but above errors come on attribute set data.

– Anees
2 mins ago





yes i have $product->save(); in end and product is saving but above errors come on attribute set data.

– Anees
2 mins ago










0






active

oldest

votes











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%2f264407%2fhow-to-set-data-for-custom-attribute-in-foreach-loop-magento-2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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%2f264407%2fhow-to-set-data-for-custom-attribute-in-foreach-loop-magento-2%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

“%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

夢乃愛華...