Skip to content

2.2.6 Products with global Tier Prices cannot be updated #18154

@davidverholen

Description

@davidverholen

Preconditions

  1. Magento 2.2.6

Steps to reproduce

  1. Set Price Scope to Website (Stores -> Configuration -> Catalog -> Catalog -> Prices)
  2. Create a Product that has at least one tier price with global scope (all websites)
  3. Save Product
  4. Try to update Product (reproduced via Rest API - without even sending new tier prices - and Backend Save)

Expected result

  1. Product Values are updated

Actual result

  1. Exception: Unique constraint violation

The Problem seems to be here:
https://github.com/magento/magento2/blob/2.2.6/app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php#L86

While the Interface defines int as return type (not strict, only per type hint), the actual model behind the interface also allows string and returns a string.

As a result $isGlobal is false (although it should be true) because of strict comparison.

This leads to the $old array being empty and finally to Magento trying to insert the values although they already exist in the db (which then causes the Unique Constraint Violation error).

An elegant workaround with a plugin on getWebsiteId (cast value to int) seems very risky if in some other place the system expects it to be a string.

Metadata

Metadata

Assignees

Labels

Component: CatalogFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions