This article talks about the issue, where products created/updated programmatically, appear to have the Disabled status and are not displayed on the store front, or are assigned to the wrong store views.
Affected products and versions
- Magento Commerce Cloud, Magento Commerce, Magento Open Source
When the catalog products get created or updated programmatically from a script with Magento application bootstrapped, products might have Disabled status and/or assigned to the wrong store views.
The issue might appear because of ACL restrictions set for the Magento instance admin roles. In case of bootstrapped application, there will be no initialized admin sessions with appropriate ACL settings. That would cause validations to fail in the Magento_AdminGws module, which is responsible for permissions check on such actions.
Set a dynamic DI preference for the
Magento\Framework\Authorization\PolicyInterface, as described in the ObjectManager>Programmatic product updates topic.