Description
Preconditions (*)
- Magento 2.4.2
- Atleast 2 store views
- 1 product which is assigned to atleast 2 store views
- Price scope is set to global
Steps to reproduce (*)
- Set price scope to website in app/etc/config.php
- Initial:
'price' => [
'scope' => null,
],
- New:
'price' => [
'scope' => 1,
],
- Execute
bin/magento app:config:import
- Clean magento cache
bin/magento cache:clean
Expected result (*)
- When I now save different product prices for each website it should save the values for each website
Actual result (*)
- The price only gets saved for the Default website
Solution
The underlying problem is that in the table catalog_eav_attribute
the value for is_global
is '1' (= global scope) for the price attribute if you set the price scope to website via the config.php. This leads to \Magento\Catalog\Model\Product\Attribute\Backend\Price::Magento\Catalog\Model\Product\Attribute\Backend::afterSave() not saving the price for each store as it thinks price is a global attribute.
When changing the price scope to website via adminhtml (as seen in the DevDocs the column is_global
in the table catalog_eav_attribute
is set to '2' (=website scope) for the price attribute and everything works as supposed.
So the solution would be to set the is_global
column in the table catalog_eav_attribute
to '2' or '1' for the price attribute when changing the price scope via the config.php file.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
The Severity is S1 as now I have to goto every database we have and set the value is_global
in the table catalog_eav_attribute
to '2' for the price attribute, which is something I definitly don't want to do in production environments. I cannot set the price scope via adminhtml as it's blocked as the config value is present in the config.php. So there is a workaround for this but it's wonky as hell.