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

How can saying a song's name be a copyright violation?

Reverse dictionary where values are lists

Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?

Determining Impedance With An Antenna Analyzer

What does “the session was packed” mean in this context?

What reasons are there for a Capitalist to oppose a 100% inheritance tax?

Detention in 1997

Should I tell management that I intend to leave due to bad software development practices?

Avoiding the "not like other girls" trope?

Unlock My Phone! February 2018

How do I gain back my faith in my PhD degree?

iPad being using in wall mount battery swollen

Short story with a alien planet, government officials must wear exploding medallions

What are some good books on Machine Learning and AI like Krugman, Wells and Graddy's "Essentials of Economics"

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

Why no variance term in Bayesian logistic regression?

How to show a landlord what we have in savings?

Can compressed videos be decoded back to their uncompresed original format?

Do UK voters know if their MP will be the Speaker of the House?

Why is consensus so controversial in Britain?

Why didn't Miles's spider sense work before?

Ambiguity in the definition of entropy

Is it logically or scientifically possible to artificially send energy to the body?

What method can I use to design a dungeon difficult enough that the PCs can't make it through without killing them?



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













1















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.










share|improve this question
























  • Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup

    – Sanjay Gohil
    2 days ago















1















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.










share|improve this question
























  • Add error_reporting(1); ini_set('max_execution_time', 0); on your code startup

    – Sanjay Gohil
    2 days ago













1












1








1


0






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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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










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%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















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%2f268161%2funable-to-save-configurable-product-programmatically-in-magento2%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

Sum ergo cogito? 1 nng

三茅街道4182Guuntc Dn precexpngmageondP