Closed
Description
Preconditions
- Magento 2.1.2
- PHP 7
- Mysql 5.6
Steps to reproduce
- Create a CLI command to create/update a production
- Execute the comment (new product)
- Execute the comment (update product)
Expected result
- New Product: values are saved on "All Store Views"
- Update Product: values are saved on "All Store Views"
Actual result
- New Product: values are saved on "All Store Views"
- Update Product: values are saved on "Default Store View"
Seems like the product repository class overrides the product store id and always assign default store id
app/code/Magento/Catalog/Model/ProductRepository.php#L530
$productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();
The only way to work around this issue is by getting the existing product with explicit parameter:
$product = $this->_productRepository->get($sku, true, 0);
and use the deprecated save method of Magento\Framework\Model\AbstractModel class at line 629.
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe 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.4-develop branchAffects non-critical data or functionality and does not force users to employ a workaround.