0

I'm creating simple product and assign that product to configure product and when simple product is assign it's parent category is will be change to default category .. How can i done this???

This is my code.....

 $_product = $objectManager->create('Magento\Catalog\Model\Product')->load($newId);
                    $_product->setNewVariationsAttributeSetId($attributeSetId);
                    $_product->setAssociatedProductIds($associatedProductIds);// Setting Associated Products
                    $_product->setCanSaveConfigurableAttributes(true);
                    $_product->setVisibility(3);
                    $_product->setCategoryIds(array(2));
                    $_product->save();

           
New contributor
aasiya shaikh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

aasiya shaikh is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.