Skip to content

Problems with price scope and config.php #33559

Open
@t-heuser

Description

@t-heuser

Preconditions (*)

  1. Magento 2.4.2
  2. Atleast 2 store views
  3. 1 product which is assigned to atleast 2 store views
  4. Price scope is set to global

Steps to reproduce (*)

  1. Set price scope to website in app/etc/config.php
  • Initial:
'price' => [
     'scope' => null,
],
  • New:
'price' => [
     'scope' => 1,
],
  1. Execute bin/magento app:config:import
  2. Clean magento cache bin/magento cache:clean

Expected result (*)

  1. When I now save different product prices for each website it should save the values for each website

Actual result (*)

  1. 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.

Metadata

Metadata

Labels

Area: CatalogComponent: ConfigIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.2Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions