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













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

Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

БиармияSxpst500bh2ntaf! 3h2r