[Sales] add getMailer and Email-Queues - #5625
Conversation
|
@sreichel i'm curious about this part: $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())and their ignored errors: But shouldn't this cause a big PHP Error crash? Edit: I'm dumb, |
|
|
@sreichel your comments on this? Is this MR ready? or should there be more/less? |
There was a problem hiding this comment.
Pull request overview
This PR refactors Sales email sending to centralize mailer/payment-block generation and expands usage of the Email Queue to additional Sales emails (invoice, shipment, credit memo), while also tightening PHPStan typing and generics across Sales/Payment/Checkout.
Changes:
- Introduces
Mage_Sales_Model_Abstract::getMailer()andgetPaymentBlockHtml()and migrates Sales email senders to use them. - Queues invoice/shipment/credit memo emails via
Mage_Core_Model_Email_Queue(similar to existing order email queueing) and adds per-entity email event constants. - Improves PHPStan signal by refining docblocks/generics, return types, and removing several baseline ignores.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| app/code/core/Mage/Sales/Model/Resource/Order/Comment/Collection/Abstract.php | Narrows collection generic template type to the new Sales comment abstract base. |
| app/code/core/Mage/Sales/Model/Order/Shipment/Comment.php | Moves shipment comments to the shared comment abstract base; adds strict types. |
| app/code/core/Mage/Sales/Model/Order/Shipment.php | Uses shared mailer/payment HTML helper and queues shipment emails with new event constants. |
| app/code/core/Mage/Sales/Model/Order/Invoice/Comment.php | Moves invoice comments to the shared comment abstract base. |
| app/code/core/Mage/Sales/Model/Order/Invoice.php | Uses shared mailer/payment HTML helper and queues invoice emails with new event constants. |
| app/code/core/Mage/Sales/Model/Order/Creditmemo/Comment.php | Moves credit memo comments to the shared comment abstract base. |
| app/code/core/Mage/Sales/Model/Order/Creditmemo.php | Uses shared mailer/payment HTML helper and queues credit memo emails with new event constants. |
| app/code/core/Mage/Sales/Model/Order/Comment/Abstract.php | Adds a new abstract base class to consolidate comment model magic-method PHPDocs. |
| app/code/core/Mage/Sales/Model/Order.php | Uses shared mailer/payment HTML helper and modernizes copy-to checks. |
| app/code/core/Mage/Sales/Model/Abstract.php | Adds getMailer(), getPaymentBlockHtml(), and consolidates _getEmails() implementation. |
| app/code/core/Mage/Sales/Block/Order/Comments.php | Specifies generics for comment collections to satisfy static analysis. |
| app/code/core/Mage/Payment/Helper/Data.php | Tightens return type documentation for getInfoBlock(). |
| app/code/core/Mage/Payment/Block/Info.php | Fixes docblock wording and adds missing magic-method annotations. |
| app/code/core/Mage/Checkout/Helper/Data.php | Improves typing for _getEmails() and avoids boolean-ish checks on arrays. |
| .phpstan.dist.baselines/notEqual.notAllowed.php | Removes now-resolved ignore entries related to loose comparisons. |
| .phpstan.dist.baselines/missingType.iterableValue.php | Removes resolved iterable-value-type ignores for updated _getEmails() docs. |
| .phpstan.dist.baselines/missingType.generics.php | Removes resolved generics-related ignores after doc updates. |
| .phpstan.dist.baselines/foreach.nonIterable.php | Removes resolved foreach-type ignores after copy-to checks were tightened. |
| .phpstan.dist.baselines/empty.notAllowed.php | Removes/reduces ignores after replacing empty() with stricter checks in touched areas. |
| .phpstan.dist.baselines/booleanNot.exprNotBoolean.php | Removes resolved ignores after avoiding negation of array |
| .phpstan.dist.baselines/booleanAnd.leftNotBoolean.php | Removes resolved ignores after avoiding && with array |
| .phpstan.dist.baselines/argument.type.php | Removes resolved ignores after tightening types around payment info blocks/emulation. |
| $emailQueue = Mage::getModel('core/email_queue'); | ||
| $emailQueue->setEntityId($this->getId()) | ||
| ->setEntityType(self::ENTITY) | ||
| ->setEventType(self::EMAIL_EVENT_NAME_NEW_SHIPMENT) | ||
| ->setIsForceCheck(true); |
| $emailQueue = Mage::getModel('core/email_queue'); | ||
| $emailQueue->setEntityId($this->getId()) | ||
| ->setEntityType(self::ENTITY) | ||
| ->setEventType(self::EMAIL_EVENT_NAME_UPDATE_SHIPMENT) | ||
| ->setIsForceCheck(true); |
| $emailQueue = Mage::getModel('core/email_queue'); | ||
| $emailQueue->setEntityId($this->getId()) | ||
| ->setEntityType(self::ENTITY) | ||
| ->setEventType(self::EMAIL_EVENT_NAME_NEW_INVOICE) | ||
| ->setIsForceCheck(true); |
| $emailQueue = Mage::getModel('core/email_queue'); | ||
| $emailQueue->setEntityId($this->getId()) | ||
| ->setEntityType(self::ENTITY) | ||
| ->setEventType(self::EMAIL_EVENT_NAME_UPDATE_INVOICE) | ||
| ->setIsForceCheck(true); |
| $emailQueue = Mage::getModel('core/email_queue'); | ||
| $emailQueue->setEntityId($this->getId()) | ||
| ->setEntityType(self::ENTITY) | ||
| ->setEventType(self::EMAIL_EVENT_NAME_NEW_CREDITMEMO) | ||
| ->setIsForceCheck(true); |
| $emailQueue = Mage::getModel('core/email_queue'); | ||
| $emailQueue->setEntityId($this->getId()) | ||
| ->setEntityType(self::ENTITY) | ||
| ->setEventType(self::EMAIL_EVENT_NAME_UPDATE_CREDITMEMO) | ||
| ->setIsForceCheck(true); |
| * @method $this setParentId(int $value) | ||
| * @method $this setStoreId(int $value) | ||
| */ | ||
| abstract class Mage_Sales_Model_Order_Comment_Abstract extends Mage_Sales_Model_Abstract {} |
|
@sreichel your opinion on |


Description (*)
getMailerhelper function to be easier overwritten.While touching this part, maybe we could discuss other Sales E-Mails related ideas?
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)