Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,30 @@ public function afterSetCapture(InvoiceService $subject, bool $result, $invoiceI

return $result;
}

/**
* @param object $subject
* @param callable $proceed
* @param array $orderItemsQtyToInvoice
* @param bool $force
*/
public function aroundPrepareItemsQty(
Copy link
Owner Author

Choose a reason for hiding this comment

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

@CodeAnt-AI ask: Are you sure I can create an around plugin here? I’m trying to do it for a method that is private.

Copy link

Choose a reason for hiding this comment

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

Answer:

Magento plugins only intercept public methods. If you’re trying to apply an around plugin to a private method, it won’t work because Magento’s interception mechanism doesn't support private methods.

For example, if you intended to intercept a method named prepareItemsQty, ensure that the target method in the subject class is public. If it’s private, you might need to refactor the method to be public or consider an alternative approach (like using a preference) to modify its behavior.

Hope this clarifies the issue. Let me know if you have any more questions!

$subject,
callable $proceed,
Order $order,
array $orderItemsQtyToInvoice,
bool $force = false
): array {
$result = $proceed($order, $orderItemsQtyToInvoice);

if ($force) {
foreach ($result as $itemId => $qty) {
$result[$itemId] = 1;
}
}

return $result;
}


}