Skip to content

[5.x]: Changing variant sorting order, triggers CatalogPricing Job #4271

@white-lukas

Description

@white-lukas

What happened?

Description

When changing the sorting of the variants, this is triggering a Catalog Pricing Job for every variant of the product, while the sorting is only getting applied after saving the product itself, which in his turn is creating 1 Catalog Job for every variant.

Those first jobs on changing the sorting seems unnecessary as on that moment the sorting isn't actually applied yet on the live product.

Our products are mapped to elasticsearch for filtering and searching on the front-end so we are checking the EVENT_AFTER_EXEC event to push changes to elasticsearch, but this is creating a bunch of unnecessary load, especially when you have products with 100+ variants.

Steps to reproduce

  1. have a product with multiple variants
  2. Change the sorting of the variants
  3. For every variant a catalog pricing job is created
  4. After saving the product 1 catalog pricing job is created that contains all the variants

Expected behavior

Changing order doesn't trigger a catalog pricing job

Craft CMS version

5.9.17

Craft Commerce version

5.6.1

PHP version

8.3

Operating system and version

No response

Database type and version

mysql 8.0

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions