Open snoop0x7b opened 2 weeks ago
Fourth logic error I noticed...
$categoryNames = []; foreach ($categories as $category) { $categoryNames[] = $category->getName(); }
You guys overwrite categoryNames for each item in the loop, so as a result you only get category names from the last item in the quote.
Also FYI - This is what that SQL error log looks like.
e
.* FR...', Array)e
.* FR...', Array)e
.* FR...', Array)
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Basically what's going on is
` private function getCartCategories(CartInterface $quote): string { if (!$quote) { return ''; }
In this code -
It's assumed that the quote item is in a category. This should be checked prior to doing this query.
Second, this is a query in a loop. You could easily aggregate the category IDs and do the query after.
Third, you're selecting ALL attributes even though you only use name. It's a best practice in Magento to only fetch the attributes you actually need.