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

Does high air pressure throw off wheel balance? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Should we be closing questions more regularly?How much should I inflate my tire?Which tire pressure is right for my 2008 Toyota Yaris's front tires?Should I let air out of my tires?Tire Pressure Adjustments When NeededRadial tires: Do they bulge at too high pressure?Cold weather tire pressure adjustmentHow does tire pressure vary with altitude?Why does a tire have the same air pressure when mounted on the car and when not?What does tire size have to do with the capabilities of an air compressor?Tire pressure with tires on vs off the car

Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?

Inventory management after order created via rest API in Magento 2.x version ( without cart)Magento - Create order using REST APILocalization for Cart/Quote APIs doesn't work properly in magento 2Magento 1.9 - Create order using REST APIPLacing Order Magento 2.1 REST APIREST API accessible without authorizationMagento 2.2 Inventory not getting decreased when orders are created using REST APIWhat is the usage of itemId inside Update inventory REST API?Get category meta tags via REST APIGet cart info REST APIAdding a grouped product to cart via the rest api