Skip to content

[5.7] Consolidate processing of catalog pricing jobs#4072

Open
nfourtythree wants to merge 19 commits into5.7from
nathaniel/pt-2823-5x-catalog-pricing-doesnt-update-for-purchasables-that-meet
Open

[5.7] Consolidate processing of catalog pricing jobs#4072
nfourtythree wants to merge 19 commits into5.7from
nathaniel/pt-2823-5x-catalog-pricing-doesnt-update-for-purchasables-that-meet

Conversation

@nfourtythree
Copy link
Copy Markdown
Contributor

@nfourtythree nfourtythree commented Jul 9, 2025

Description

Changing strategy on this one. Reworking to mimic how search keyword jobs combine with each other to reduce overhead

Related issues

#4054

@nfourtythree nfourtythree self-assigned this Jul 9, 2025
@nfourtythree nfourtythree requested a review from a team as a code owner July 9, 2025 10:44
@linear
Copy link
Copy Markdown

linear bot commented Jul 9, 2025

@nfourtythree nfourtythree marked this pull request as draft July 24, 2025 09:50
@nfourtythree nfourtythree force-pushed the nathaniel/pt-2823-5x-catalog-pricing-doesnt-update-for-purchasables-that-meet branch from 50c9ca8 to d0dc031 Compare April 15, 2026 13:31
@nfourtythree nfourtythree changed the base branch from 5.x to 5.7 April 15, 2026 14:04
@nfourtythree nfourtythree changed the title [5.x] Fix #4054 catalog price generation when saving a product [5.x] Consolidate processing of catalog pricing jobs Apr 15, 2026
@nfourtythree nfourtythree changed the title [5.x] Consolidate processing of catalog pricing jobs [5.7] Consolidate processing of catalog pricing jobs Apr 16, 2026
@nfourtythree nfourtythree marked this pull request as ready for review April 16, 2026 08:57
@nfourtythree nfourtythree requested a review from Copilot April 16, 2026 08:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Consolidates catalog pricing regeneration work by persisting pending work into a dedicated queue table and having a single job execution reserve/consume that work, reducing queue overhead and aligning behavior with other consolidated job patterns (related to #4054).

Changes:

  • Added commerce_catalogpricing_queue table + ActiveRecord to store/merge pending regeneration work (by purchasable IDs or rule IDs).
  • Updated CatalogPricing::createCatalogPricingJob() to enqueue/merge work into the queue table and push a consolidated CatalogPricing job.
  • Updated CatalogPricing queue job to reserve a queue row, run generation, and delete/release the row based on success/failure.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/services/CatalogPricing.php Writes/merges queue rows for pending catalog pricing work; adds reservation/release/delete helpers; changes job scheduling to consolidated processing.
src/records/CatalogPricingQueue.php New ActiveRecord representing queue rows (type, ids JSON, reserved flag).
src/queue/jobs/CatalogPricing.php Consolidated job execution: reserves a queue row, generates prices, then deletes/releases the row.
src/migrations/m260407_000000_add_catalog_pricing_queue_table.php Adds the new queue table + indexes/FK for upgrades.
src/migrations/Install.php Creates the queue table + indexes/FK for fresh installs.
src/db/Table.php Adds Table::CATALOG_PRICING_QUEUE constant.
src/Plugin.php Bumps schema version to trigger migration execution.
CHANGELOG-WIP.md Documents new extensibility additions (table/record/service methods).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/services/CatalogPricing.php Outdated
Comment thread src/services/CatalogPricing.php Outdated
Comment thread src/queue/jobs/CatalogPricing.php
Comment thread CHANGELOG-WIP.md Outdated
Comment thread src/services/CatalogPricing.php
Comment thread src/services/CatalogPricing.php Outdated
Comment thread src/services/CatalogPricing.php Outdated
nfourtythree and others added 8 commits April 16, 2026 10:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Make sure if there is already an "all ids" row or the request to the method is asking to process "all ids". That row is actually being created

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…purchasables-that-meet' of github.com:craftcms/commerce into nathaniel/pt-2823-5x-catalog-pricing-doesnt-update-for-purchasables-that-meet
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…purchasables-that-meet' of github.com:craftcms/commerce into nathaniel/pt-2823-5x-catalog-pricing-doesnt-update-for-purchasables-that-meet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants