magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.53k stars 9.31k forks source link

(Custom) price attributes for website scope were only saved via API, if a value for this attribute and scope already exists or no other attribute is set for the scope #34971

Closed attheCube closed 2 years ago

attheCube commented 2 years ago

Preconditions (*)

  1. Magento 2.4.3-p1
  2. Multiple websites
  3. Price scope: website

Steps to reproduce (*)

  1. Create 2 websites and according store views
  2. Add a product in global scope with all needed Attributes
  3. Set a few Attributes in a specific store scope via API. (Request example below)
  4. Add a new price-attribute called "test_price".
  5. Set test_price via API for the same store scope as in point 3 above. (Request example below)

Request examples:

Step 3: Set data for special store scope Call: {{base_url}}/rest/[store_code]/V1/products

{
    "product": {
        "status": 1,
        "name": "Test 1 2 333  111111",
        "price": 125.12,
        "custom_attributes": [
            {
                "attribute_code": "short_description",
                "value": "abcdefg ggg"
            }
        ],
        "sku": "Test1"
    }
}

Step 4: Set test_price for the same store scope Call: {{base_url}}/rest/[store_code]/V1/products

{
    "product": {
        "status": 1,
        "name": "Test 1 2 333  111111",
        "price": 125.12,
        "custom_attributes": [
            {
                "attribute_code": "short_description",
                "value": "abcdefg ggg"
            },
            {
                "attribute_code": "test_price",
                "value": 101.11
            }
        ],
        "sku": "Test1"
    }
}

Expected result (*)

  1. test price will be set for website scope of chosen store => 101.11

Actual result (*)

  1. test price is not set for website scope of chosen store.
  2. The database shows no entry for test_price in website scope

It seems to be an issue for each attribute based on price logic. Values may only be written in database, if there are no other attribute values set for current website / websites default store.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 2 years ago

Hi @attheCube. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

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

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

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

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

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

attheCube commented 2 years ago

Seems to be related to https://github.com/magento/magento2/pull/34665 but the solution there is not working properly for this case. We confirmed this issue existing also in vanilla Magento open Source 2.4.3 and Commerce 2.4.4-beta3 .

m2-assistant[bot] commented 2 years ago

Hi @engcom-Echo. 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: :point_down:


engcom-Echo commented 2 years ago

Hi @attheCube,

Thank you for reporting the issue.

I have tried this issue on the fresh installation (Magento 2.4-dev/2.4.3-P1) but I am not able to reproduce it.

The special price setup and its API is working as expected. Could you please provide more details on steps 3, 4, 5 and the provided request sample is not working so please provide the exact request which is causing the issue ?

Thanks

attheCube commented 2 years ago

Hi @engcom-Echo ,

I adjusted the description. Please check again.

Thank you.

engcom-Hotel commented 2 years ago

Hi @attheCube, I have tried this issue on the fresh installation (Magento 2.4-dev/2.4.3-P1) but I am not able to reproduce it.

It seems you are using the wrong rest API to set the special price. Use this API request to set the special price.

Hope it helps. Let me know if you are still facing this issue or provide more relevant details if you think it is a Magento core issue.

Thanks.

attheCube commented 2 years ago

Hi @engcom-Hotel , I updated the issue description. The problem does not rely on using the wrong API-endpoint.

If you create an own price attribute, you need to use the endpoint described above.

Please check again.

Thanks a lot.

attheCube commented 2 years ago

Here, you'll find a Screencast how the issue will be reproduced: https://www.gothicgirly.de/rgtrhzthrsgfsee4t5454zhrtz/2022-02-03-18-09-26.mkv

m2-assistant[bot] commented 2 years ago

Hi @engcom-Lima. 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: :point_down:

engcom-Lima commented 2 years ago

Hi @attheCube, I tried reproducing the issue on the latest 2.4-develop branch following all the steps mentioned in the description as well as by referring the video, however the issue is not reproducible on 2.4-develop branch.

Steps followed to reproduce the issue:

  1. Install fresh Magento 2.4-develop instance
  2. Login to admin panel and add a new Website, Store and Store View. So in total I have 2 websites (Main Website, Second Website) with their respective stores and store views. image
  3. Change price scope from Global to Website. Stores->Configuration->Catalog->Catalog->Price image
  4. Create a custom price attribute testattr2 and assign it to an attribute set, it will be visible on Product Edit Page
  5. Assign a value to testattr2 eg: 555 and save the product

image

  1. Set a few Attributes in a specific store scope via API. In my case I updated name, short_description, price for second store view second_store_view Screenshot 2022-02-10 at 2 03 25 PM

Notice: In response we get the custom testattr2 value as expected i.e 555 Also the records in database are expected

image

  1. Now through the same endpoint {{base_url}}/rest/[store_code]/V1/products update our custom attribute testattr2 for same store view. I updated with value 300 Screenshot 2022-02-10 at 2 10 52 PM

Notice: As you can see in response we do get the updated value i.e. 300, Also the changes are reflected in the DB as well as in the admin panel

Change in the DB image

Change in the Admin Panel image

Thank you for your crystal clear description as well as the reference video however the issue is not reproducible on 2.4-develop. Can you please try reproducing this on latest 2.4-develop instance or incase if I have missed any steps then please let me know, I will reverify it again.

Thanks!

engcom-Hotel commented 2 years ago

Dear @attheCube,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Regards

Detzler commented 1 year ago

@engcom-Hotel @attheCube

I can confirm this bug also for the default "price" attribute. It appears when catalog prices are set to website-scope instead to global in the catalog settings.

Now we are workarounding by using the /products/base-price rest endpoint.

Need to be fixes asap.

engcom-Hotel commented 1 year ago

Hello @Detzler,

Thanks for the reply!

We have closed this issue as we do not get any response from the reporter for 14 days. But we still reopen and work on it.

So I request you to please go through with the comment, made by us and let us know if any is missed by us in order to reproduce this issue.

Thanks