Unable to save configurable product programmatically in magento2Magento 2 hardcoded attribute setsProceeding to an exception page after save new categoryMagento2: How to update the product price programaticallyUnset custom data from product attributeMagento 2.1 Create a filter in the product grid by new attributeI want to add parent product to cart using child product id, it's configurable options in magento 2.1Configurable Product Programmatically Configurations is emptyMagento 2: Add a product to the cart programmaticallyError at order shippingMagento 2 Error
Arrow those variables!
Avoiding the "not like other girls" trope?
Expand and Contract
In 'Revenger,' what does 'cove' come from?
Why didn't Boeing produce its own regional jet?
Is "remove commented out code" correct English?
Could the museum Saturn V's be refitted for one more flight?
Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?
Should I cover my bicycle overnight while bikepacking?
Short story with a alien planet, government officials must wear exploding medallions
Why was the shrinking from 8″ made only to 5.25″ and not smaller (4″ or less)?
How do I handle a potential work/personal life conflict as the manager of one of my friends?
Is it acceptable for a professor to tell male students to not think that they are smarter than female students?
How seriously should I take size and weight limits of hand luggage?
Apex Framework / library for consuming REST services
I would say: "You are another teacher", but she is a woman and I am a man
Can I run a new neutral wire to repair a broken circuit?
Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?
Does the Idaho Potato Commission associate potato skins with healthy eating?
Is it possible to create a QR code using text?
Why is this clock signal connected to a capacitor to gnd?
What does the expression "A Mann!" means
Is it logically or scientifically possible to artificially send energy to the body?
What is the most common color to indicate the input-field is disabled?
Unable to save configurable product programmatically in magento2
Magento 2 hardcoded attribute setsProceeding to an exception page after save new categoryMagento2: How to update the product price programaticallyUnset custom data from product attributeMagento 2.1 Create a filter in the product grid by new attributeI want to add parent product to cart using child product id, it's configurable options in magento 2.1Configurable Product Programmatically Configurations is emptyMagento 2: Add a product to the cart programmaticallyError at order shippingMagento 2 Error
I am try to save configurable product programmatically, But when i just hit save button in admin panel after the configurable product save the simple product only.
<?php
$productId = 612; // Configurable Product Ids
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($productId); // Load Configurable Product
$product->setName('90i111');
// $product->save();
$attributeModel = $objectManager->create('MagentoConfigurableProductModelProductTypeConfigurableAttribute');
$position = 0;
$attributes = array(90); // Super Attribute Ids Used To Create Configurable Product
$associatedProductIds = array($simple_productid); //Product Ids Of Associated Products
foreach ($attributes as $attributeId)
$data = array('attribute_id' => $attributeId, 'product_id' => $productId, 'position' => $position);
$position++;
$attributeModel->setData($data)->save();
$product->setTypeId("configurable"); // Setting Product Type As Configurable
$product->setAffectConfigurableProductAttributes(4);
$objectManager->create('MagentoConfigurableProductModelProductTypeConfigurable')->setUsedProductAttributeIds($attributes, $product);
$product->setNewVariationsAttributeSetId(4); // Setting Attribute Set Id
$product->setAssociatedProductIds($associatedProductIds);// Setting Associated Products
$product->setCanSaveConfigurableAttributes(true);
$product->save();
Can anyone help me to solve this.
Thanks in advance.
magento2
add a comment |
I am try to save configurable product programmatically, But when i just hit save button in admin panel after the configurable product save the simple product only.
<?php
$productId = 612; // Configurable Product Ids
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($productId); // Load Configurable Product
$product->setName('90i111');
// $product->save();
$attributeModel = $objectManager->create('MagentoConfigurableProductModelProductTypeConfigurableAttribute');
$position = 0;
$attributes = array(90); // Super Attribute Ids Used To Create Configurable Product
$associatedProductIds = array($simple_productid); //Product Ids Of Associated Products
foreach ($attributes as $attributeId)
$data = array('attribute_id' => $attributeId, 'product_id' => $productId, 'position' => $position);
$position++;
$attributeModel->setData($data)->save();
$product->setTypeId("configurable"); // Setting Product Type As Configurable
$product->setAffectConfigurableProductAttributes(4);
$objectManager->create('MagentoConfigurableProductModelProductTypeConfigurable')->setUsedProductAttributeIds($attributes, $product);
$product->setNewVariationsAttributeSetId(4); // Setting Attribute Set Id
$product->setAssociatedProductIds($associatedProductIds);// Setting Associated Products
$product->setCanSaveConfigurableAttributes(true);
$product->save();
Can anyone help me to solve this.
Thanks in advance.
magento2
Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup
– Sanjay Gohil
2 days ago
add a comment |
I am try to save configurable product programmatically, But when i just hit save button in admin panel after the configurable product save the simple product only.
<?php
$productId = 612; // Configurable Product Ids
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($productId); // Load Configurable Product
$product->setName('90i111');
// $product->save();
$attributeModel = $objectManager->create('MagentoConfigurableProductModelProductTypeConfigurableAttribute');
$position = 0;
$attributes = array(90); // Super Attribute Ids Used To Create Configurable Product
$associatedProductIds = array($simple_productid); //Product Ids Of Associated Products
foreach ($attributes as $attributeId)
$data = array('attribute_id' => $attributeId, 'product_id' => $productId, 'position' => $position);
$position++;
$attributeModel->setData($data)->save();
$product->setTypeId("configurable"); // Setting Product Type As Configurable
$product->setAffectConfigurableProductAttributes(4);
$objectManager->create('MagentoConfigurableProductModelProductTypeConfigurable')->setUsedProductAttributeIds($attributes, $product);
$product->setNewVariationsAttributeSetId(4); // Setting Attribute Set Id
$product->setAssociatedProductIds($associatedProductIds);// Setting Associated Products
$product->setCanSaveConfigurableAttributes(true);
$product->save();
Can anyone help me to solve this.
Thanks in advance.
magento2
I am try to save configurable product programmatically, But when i just hit save button in admin panel after the configurable product save the simple product only.
<?php
$productId = 612; // Configurable Product Ids
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$product = $objectManager->create('MagentoCatalogModelProduct')->load($productId); // Load Configurable Product
$product->setName('90i111');
// $product->save();
$attributeModel = $objectManager->create('MagentoConfigurableProductModelProductTypeConfigurableAttribute');
$position = 0;
$attributes = array(90); // Super Attribute Ids Used To Create Configurable Product
$associatedProductIds = array($simple_productid); //Product Ids Of Associated Products
foreach ($attributes as $attributeId)
$data = array('attribute_id' => $attributeId, 'product_id' => $productId, 'position' => $position);
$position++;
$attributeModel->setData($data)->save();
$product->setTypeId("configurable"); // Setting Product Type As Configurable
$product->setAffectConfigurableProductAttributes(4);
$objectManager->create('MagentoConfigurableProductModelProductTypeConfigurable')->setUsedProductAttributeIds($attributes, $product);
$product->setNewVariationsAttributeSetId(4); // Setting Attribute Set Id
$product->setAssociatedProductIds($associatedProductIds);// Setting Associated Products
$product->setCanSaveConfigurableAttributes(true);
$product->save();
Can anyone help me to solve this.
Thanks in advance.
magento2
magento2
edited 2 days ago
Sanjay Gohil
478215
478215
asked 2 days ago
AneesAnees
15712
15712
Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup
– Sanjay Gohil
2 days ago
add a comment |
Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup
– Sanjay Gohil
2 days ago
Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup
– Sanjay Gohil
2 days ago
Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup
– Sanjay Gohil
2 days 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%2f268161%2funable-to-save-configurable-product-programmatically-in-magento2%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%2f268161%2funable-to-save-configurable-product-programmatically-in-magento2%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
Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup
– Sanjay Gohil
2 days ago