Description
Summary
Preconditions (*)
- Products added to cart
Steps to reproduce (*)
- Enter PDP with profiler enabled
- Quote is not expired and the quote is fully loaded to check this, performance suffers
Expected result (*)
persistent_quote
observer does not load the quote before it's absolutely necessary
Actual result (*)
persistent_quote
is loading the full quote with expensiveassignProducts
function call
Magento_Persistent
adds controller_action_predispatch
event persistent_quote
observer. On non-cart, non-checkout pages(e.g. PDP) it's loading quote and it impacts the TTFB significantly. Due to the observer's private function declarations, overriding the logic inside the observer class requires developers to add class preference or patch the observer class directly. There is no "ok" way to implement workaround for this.
Both of these calls could be simplified by checking the quote table data directly. The business logic will still be satisfied. If the quote has to be expired, then the quote probably needs to be still loaded fully.
Examples
class QuoteResourceWrapper
{
public function __construct(
private readonly ResourceConnection $resourceConnection
) {
}
public function isActive(?int $quoteId): bool
{
if (empty($quoteId)) {
return false;
}
$table = $this->resourceConnection->getTableName('quote');
$connection = $this->resourceConnection->getConnection();
$select = $connection->select()
->from($table, 'is_active')
->where('entity_id = ?', $quoteId);
return $connection->fetchOne($select) == true;
}
public function isPersistent(?int $quoteId): bool
{
if (empty($quoteId)) {
return false;
}
$table = $this->resourceConnection->getTableName('quote');
$connection = $this->resourceConnection->getConnection();
$select = $connection->select()
->from($table, 'is_persistent')
->where('entity_id = ?', $quoteId);
return $connection->fetchOne($select) == true;
}
}
Proposed solution
Do not load quote fully if not needed.
I have prepared a sample class that could be used as a wrapper for getting the required data instead, see Examples
Release note
No response
Triage and priority
- 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”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Activity
m2-assistant commentedon May 28, 2025
Hi @adamwaclawczyk. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.
@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ 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, join the Community Contributions Triage session to discuss the appropriate ticket.
m2-assistant commentedon May 28, 2025
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: 👇
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branchDetails
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced 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!
Issue: Confirmed
once verification is complete.m2-assistant commentedon May 29, 2025
Hi @engcom-Hotel. 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: 👇
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branchDetails
- If the issue is reproducible on2.4-develop
branch, please, add the labelReproduced 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!
Issue: Confirmed
once verification is complete.engcom-Hotel commentedon May 29, 2025
Hello @adamwaclawczyk,
Thanks for the report & collaboration!
We have tried to reproduce the issue in the latest development branch (Vanilla) i.e. 2.4-develop but it seems the issue is not reproducible for us. Please refer to the below screenshot for reference:
Let us know if we missed anything.
Thanks
22 remaining items