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.

Activity

m2-assistant

m2-assistant commented on Jul 22, 2021

@m2-assistant

Hi @oneserv-heuser. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

t-heuser

t-heuser commented on Jul 22, 2021

@t-heuser
Author

I can confirm that this issue also exists on a vanilla magento instance.

mrtuvn

mrtuvn commented on Jul 23, 2021

@mrtuvn
Contributor

just curiously have you import correct price scope ? Would be great if you can share file config.php in description
['system']['default']['catalog']['price']['scope']

t-heuser

t-heuser commented on Jul 23, 2021

@t-heuser
Author

@mrtuvn What exactly do you mean? Yes, the value I've changed has the path ['system']['default']['catalog']['price']['scope']. Before the value was null and now it's 1. 1 is also the value which the option in the select for the configuration of the price scope has.

m2-assistant

m2-assistant commented on Jul 29, 2021

@m2-assistant

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

    2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

    3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

    4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

    5. Add label Issue: Confirmed once verification is complete.

    6. Make sure that automatic system confirms that report has been added to the backlog.

engcom-November

engcom-November commented on Aug 2, 2021

@engcom-November
Contributor

Verified the issue on Magento2.4-develop branch and the issue is reproducible:

Steps to reproduce:

  1. Magento Setup 2 Store views (Ref Guide)
  2. Create/Edit a product and assign to both the Stores (Admin - Catalog - Products) and save
  3. Set the price scope to 'Global' (Admin - Stores - Configuration - Catalog - Catalog - Price - Price Scope - Global) and Save
  4. Set the price scope to "Website" in your Magento root/app/etc/config.php
'system' => [
        'default' => [
                'catalog' => [
                        'price' =>[
                             'scope' => 1
                         ]
                 ]
         ]
],
  1. Execute bin/magento app:config:import
  2. Clean magento cache bin/magento cache:clean
  3. Admin - Verify Price scope is changed to Website - Price scope is changed to Website.
  4. Navigate to Admin - Catalog - Products - Edit the same product - Change the scope to new Store view - Change the Price and Save
    Issue: User is able to save the product but price is not getting changed. Default Price is displayed.
    User is able to save different price only when scope is set to "All Store Views"
    For Scope "Default Store View" and "New Store View" - New Price saved is not getting updated.

Screenshot 2021-08-25 at 9 48 32 PM

Screenshot 2021-08-25 at 9 48 48 PM

magento-engcom-team

magento-engcom-team commented on Aug 2, 2021

@magento-engcom-team
Contributor

✅ Confirmed by @engcom-November
Thank you for verifying the issue. Based on the provided information internal tickets MC-42963 were created

Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

34 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Participants

    @mrtuvn@rmsundar1@zamu87@magento-engcom-team@engcom-Bravo

    Issue actions

      Problems with price scope and config.php · Issue #33559 · magento/magento2