I’m working on a custom shipping module, and require data from a simple product that’s a child to a configurable product when processing a shipment. Therefore in my module, I have a Carrier.php that extends MagentoShippingModelCarrierAbstractCarrier
, and in there I have the method requestToShipment
. However I am struggling to obtain the simple product data from within this method.
I have tried using $request->getOrderShipment()->getItemsCollection()
, however this fetches the configurable product IDs. Therefore I’m unable to reliably link back to the simple product without mistakenly targeting an incorrect product.
I can make use of $request->getOrderShipment()->getOrder()->getItems()
, which fetches both the simple and configurable products. However I’m back to struggling to link it to an item within the collection from the order shipment.
Finally I have tried $request->getPackages()
, but again this only fetches IDs relating back to the configurable product.
So from either one of these loops, how do I obtain the actual simple product object relating to that package/order item?
Thank you!