Closed
Description
I'm trying to programmatically create a product, but upon the first save, the price is not saved, thus returning 'NULL'. On a second save (with the identical object), the price gets saved.
Preconditions
- Magento 2.4-develop
- php v 7.2
Steps to reproduce
/** @var \Magento\Catalog\Model\Product $product */
$product = $this->productFactory->create();
$product->setSku('abc');
$product->setName('Name');
$product->setPrice(9.95);
$product->setAttributeSetId(4);
// Save once, the price does not get saved:
$this->productRepository->save($product);
// Check if the product is saved:
$product = $this->productRepository->get('abc');
$this->assertEquals('abc', $product->getSku()); // passes
$this->assertEquals('Name', $product->getName()); // passes
$this->assertEquals(9.95, $product->getPrice()); // fails (null does not equal 9.95
When I add an extra save()
-instruction it works:
// Save twice, the price gets saved:
$this->productRepository->save($product);
$this->productRepository->save($product);
Expected result
The price should be saved in the first run
Actual result
The price only gets saved the second time the save()
-method is executed
Metadata
Metadata
Assignees
Labels
Use with concrete module component label E.g. "Component: Api" + "Catalog"The issue has been fixed in 2.4-develop branchGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentA defect with this priority could have functionality issues which are not to expectations.The issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.4-develop branchMajor restrictions or short-term circumventions are required until a fix is available.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it