Magento 2 : We need to save product two time After generating Custom Option programmatically?Product custom option duplication on save within loopCreating Custom Option on Product SaveCreate custom option programatically in magento 1.7.0.1Forcing a certain custom option value when customer adding product to cartMagento add custom options to cartHow to change product name in quote item dynamicallyHow to add custom options programmatically for configurable product in Magento 2Magento 2 custom option not showing created programmaticallyI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom Options
What's the difference between "ricochet" and "bounce"?
Not taking the bishop with the knight, why?
Was Mohammed the most popular first name for boys born in Berlin in 2018?
Publishing an article in a journal without a related degree
Examples where existence is harder than evaluation
Narcissistic cube asks who are we?
How did Captain Marvel know where to find these characters?
Is it safe to keep the GPU on 100% utilization for a very long time?
Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019
What can cause an unfrozen indoor copper drain pipe to crack?
How come mathematicians published in Annals of Eugenics?
Is there an idiom that means "revealing a secret unintentionally"?
Can the president of the United States be guilty of insider trading?
Does STATISTICS IO output include Version Store reads?
Hexagonal Grid Filling
Do Monks gain the 9th level Unarmored Movement benefit when wearing armor or using a shield?
Does a surprised creature obey the 1st level spell Command?
Pre-1993 comic in which Wolverine's claws were turned to rubber?
Output the date in the Mel calendar
Was there a contingency plan in place if Little Boy failed to detonate?
What dice to use in a game that revolves around triangles?
Compactness in normed vector spaces.
What's an appropriate age to involve kids in life changing decisions?
Generating 10-character passwords, with 3-6 digits and 3-6 uppercase letters, in C++
Magento 2 : We need to save product two time After generating Custom Option programmatically?
Product custom option duplication on save within loopCreating Custom Option on Product SaveCreate custom option programatically in magento 1.7.0.1Forcing a certain custom option value when customer adding product to cartMagento add custom options to cartHow to change product name in quote item dynamicallyHow to add custom options programmatically for configurable product in Magento 2Magento 2 custom option not showing created programmaticallyI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom Options
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have work on Custom Module.
In Our Module I had use
<event name="catalog_product_save_after">
<observer name="add_custom_option" instance="NamespaceModulenameObserverAddCustomOption" />
</event>
In observer i Had Generate Product Custom Option Programmatically
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogModelProductOption')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
//$product->save();
i have use this code for generate Product custom Option.
//$product->save();
i had comment this code because it provide me Error
No Such Entity
After saving Product.
Product Options are generated Successfully in Product But Not Display in Front-end
I had Run All Commands
- setup:upgrade
- setup:static-content:deploy -f
- indexer:reindex
- cache:flush
But Custom Option Not Appears in Front-end
But When i have save product second time after saving product the Options are Appears in Front-end Without need Run any Commands.
I Need Solution to save Product One time and Get Product Option Front End
Is This Possible ?
magento2 event-observer custom-options catalog-product
add a comment |
I have work on Custom Module.
In Our Module I had use
<event name="catalog_product_save_after">
<observer name="add_custom_option" instance="NamespaceModulenameObserverAddCustomOption" />
</event>
In observer i Had Generate Product Custom Option Programmatically
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogModelProductOption')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
//$product->save();
i have use this code for generate Product custom Option.
//$product->save();
i had comment this code because it provide me Error
No Such Entity
After saving Product.
Product Options are generated Successfully in Product But Not Display in Front-end
I had Run All Commands
- setup:upgrade
- setup:static-content:deploy -f
- indexer:reindex
- cache:flush
But Custom Option Not Appears in Front-end
But When i have save product second time after saving product the Options are Appears in Front-end Without need Run any Commands.
I Need Solution to save Product One time and Get Product Option Front End
Is This Possible ?
magento2 event-observer custom-options catalog-product
I have also the same problems
– Hardik Makwana
1 hour ago
add a comment |
I have work on Custom Module.
In Our Module I had use
<event name="catalog_product_save_after">
<observer name="add_custom_option" instance="NamespaceModulenameObserverAddCustomOption" />
</event>
In observer i Had Generate Product Custom Option Programmatically
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogModelProductOption')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
//$product->save();
i have use this code for generate Product custom Option.
//$product->save();
i had comment this code because it provide me Error
No Such Entity
After saving Product.
Product Options are generated Successfully in Product But Not Display in Front-end
I had Run All Commands
- setup:upgrade
- setup:static-content:deploy -f
- indexer:reindex
- cache:flush
But Custom Option Not Appears in Front-end
But When i have save product second time after saving product the Options are Appears in Front-end Without need Run any Commands.
I Need Solution to save Product One time and Get Product Option Front End
Is This Possible ?
magento2 event-observer custom-options catalog-product
I have work on Custom Module.
In Our Module I had use
<event name="catalog_product_save_after">
<observer name="add_custom_option" instance="NamespaceModulenameObserverAddCustomOption" />
</event>
In observer i Had Generate Product Custom Option Programmatically
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogModelProductOption')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
//$product->save();
i have use this code for generate Product custom Option.
//$product->save();
i had comment this code because it provide me Error
No Such Entity
After saving Product.
Product Options are generated Successfully in Product But Not Display in Front-end
I had Run All Commands
- setup:upgrade
- setup:static-content:deploy -f
- indexer:reindex
- cache:flush
But Custom Option Not Appears in Front-end
But When i have save product second time after saving product the Options are Appears in Front-end Without need Run any Commands.
I Need Solution to save Product One time and Get Product Option Front End
Is This Possible ?
magento2 event-observer custom-options catalog-product
magento2 event-observer custom-options catalog-product
asked 1 hour ago
Bhavesh MagentoBhavesh Magento
1168
1168
I have also the same problems
– Hardik Makwana
1 hour ago
add a comment |
I have also the same problems
– Hardik Makwana
1 hour ago
I have also the same problems
– Hardik Makwana
1 hour ago
I have also the same problems
– Hardik Makwana
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
You can try using a Product Repository MagentoCatalogApiProductCustomOptionRepositoryInterface
Like this:
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogApiProductCustomOptionRepositoryInterface')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
$product->save();
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
updated it usingProductCustomOptionRepositoryInterface
, using it, save() will work without error
– magefms
52 mins ago
add a comment |
Save Product Using ProductRepositoryInterface
:-
$option = $this->_objectManager->create(MagentoCatalogModelProductOption::class)
->setProductId($_product->getId())
->setStoreId($_product->getStoreId())
->addData($arrayOption);
$option->save();
$product->addOption($option);
$productRepo = $this->_objectManager->create('MagentoCatalogApiProductRepositoryInterface');
$productRepo->save($product);
try this.......
– Rk Rathod
29 mins ago
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
add a comment |
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%2f273928%2fmagento-2-we-need-to-save-product-two-time-after-generating-custom-option-prog%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try using a Product Repository MagentoCatalogApiProductCustomOptionRepositoryInterface
Like this:
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogApiProductCustomOptionRepositoryInterface')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
$product->save();
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
updated it usingProductCustomOptionRepositoryInterface
, using it, save() will work without error
– magefms
52 mins ago
add a comment |
You can try using a Product Repository MagentoCatalogApiProductCustomOptionRepositoryInterface
Like this:
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogApiProductCustomOptionRepositoryInterface')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
$product->save();
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
updated it usingProductCustomOptionRepositoryInterface
, using it, save() will work without error
– magefms
52 mins ago
add a comment |
You can try using a Product Repository MagentoCatalogApiProductCustomOptionRepositoryInterface
Like this:
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogApiProductCustomOptionRepositoryInterface')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
$product->save();
You can try using a Product Repository MagentoCatalogApiProductCustomOptionRepositoryInterface
Like this:
$product->setHasOptions(1);
$product->setCanSaveCustomOptions(true);
foreach ($options as $arrayOption)
$isHasOptions = $product->getTypeInstance()->hasOptions($product);
$option = MagentoFrameworkAppObjectManager::getInstance()
->create('MagentoCatalogApiProductCustomOptionRepositoryInterface')
->setProductId($product->getId())
->setStoreId($product->getStoreId())
->addData($arrayOption);
$this->customoptionOperation($option, 'save');
$product->addOption($option);
$product->save();
edited 56 mins ago
answered 1 hour ago
magefmsmagefms
3,0252629
3,0252629
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
updated it usingProductCustomOptionRepositoryInterface
, using it, save() will work without error
– magefms
52 mins ago
add a comment |
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
updated it usingProductCustomOptionRepositoryInterface
, using it, save() will work without error
– magefms
52 mins ago
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
it is not working and read My Question $product->save() provide me Error No Such Entity
– Bhavesh Magento
58 mins ago
updated it using
ProductCustomOptionRepositoryInterface
, using it, save() will work without error– magefms
52 mins ago
updated it using
ProductCustomOptionRepositoryInterface
, using it, save() will work without error– magefms
52 mins ago
add a comment |
Save Product Using ProductRepositoryInterface
:-
$option = $this->_objectManager->create(MagentoCatalogModelProductOption::class)
->setProductId($_product->getId())
->setStoreId($_product->getStoreId())
->addData($arrayOption);
$option->save();
$product->addOption($option);
$productRepo = $this->_objectManager->create('MagentoCatalogApiProductRepositoryInterface');
$productRepo->save($product);
try this.......
– Rk Rathod
29 mins ago
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
add a comment |
Save Product Using ProductRepositoryInterface
:-
$option = $this->_objectManager->create(MagentoCatalogModelProductOption::class)
->setProductId($_product->getId())
->setStoreId($_product->getStoreId())
->addData($arrayOption);
$option->save();
$product->addOption($option);
$productRepo = $this->_objectManager->create('MagentoCatalogApiProductRepositoryInterface');
$productRepo->save($product);
try this.......
– Rk Rathod
29 mins ago
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
add a comment |
Save Product Using ProductRepositoryInterface
:-
$option = $this->_objectManager->create(MagentoCatalogModelProductOption::class)
->setProductId($_product->getId())
->setStoreId($_product->getStoreId())
->addData($arrayOption);
$option->save();
$product->addOption($option);
$productRepo = $this->_objectManager->create('MagentoCatalogApiProductRepositoryInterface');
$productRepo->save($product);
Save Product Using ProductRepositoryInterface
:-
$option = $this->_objectManager->create(MagentoCatalogModelProductOption::class)
->setProductId($_product->getId())
->setStoreId($_product->getStoreId())
->addData($arrayOption);
$option->save();
$product->addOption($option);
$productRepo = $this->_objectManager->create('MagentoCatalogApiProductRepositoryInterface');
$productRepo->save($product);
answered 51 mins ago
Rk RathodRk Rathod
1,579214
1,579214
try this.......
– Rk Rathod
29 mins ago
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
add a comment |
try this.......
– Rk Rathod
29 mins ago
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
try this.......
– Rk Rathod
29 mins ago
try this.......
– Rk Rathod
29 mins ago
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
it will provide Me Error No such Entity [screencast.com/t/hZhbqSSinL]
– Bhavesh Magento
just now
add a comment |
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%2f273928%2fmagento-2-we-need-to-save-product-two-time-after-generating-custom-option-prog%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
I have also the same problems
– Hardik Makwana
1 hour ago