This article provides a fix for when product status is Disabled and products are not displayed on the store front, or are assigned to the wrong store views, when created/updated programmatically.
Affected products and versions
- Adobe Commerce on cloud infrastructure 2.X.X
- Adobe Commerce on-premises 2.X.X
When the catalog products get created or updated programmatically from a script with Adobe Commerce 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 Adobe Commerce 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.
Solution for incorrect product status
Set a dynamic DI preference for the
Magento\Framework\Authorization\PolicyInterface, as described in the ObjectManager>Programmatic product updates topic in our developer documentation.