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
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
add a comment |
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
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
add a comment |
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
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
magento2
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
add a comment |
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
add a comment |
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
});
}
});
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%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
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%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
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
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