54 \
Magento\Sales\Model\Convert\OrderFactory $convertOrderFactory,
56 Json $serializer =
null 58 $this->converter = $convertOrderFactory->create();
60 $this->instanceName = \Magento\Sales\Api\Data\ShipmentInterface::class;
94 protected function prepareItems(
108 $item->isDeleted(
true);
118 $bundleSelectionAttributes = $this->serializer->unserialize(
122 if ($bundleSelectionAttributes) {
123 $qty = $bundleSelectionAttributes[
'qty'] *
$items[
$orderItem->getParentItemId()];
124 $qty = min($qty,
$orderItem->getSimpleQtyToShip());
127 $shipmentItems[] =
$item;
147 $shipmentItems[] =
$item;
149 return $this->setItemsToShipment(
$shipment, $shipmentItems);
181 private function setItemsToShipment(\
Magento\Sales\Api\Data\ShipmentInterface
$shipment, $shipmentItems)
198 if (count($childItems) <= 0) {
199 unset($shipmentItems[$key]);
206 return $shipment->setTotalQty($totalQty);
220 if (empty(
$data[
'number'])) {
221 throw new \Magento\Framework\Exception\LocalizedException(
222 __(
'Please enter a tracking number.')
227 $this->trackFactory->create()->addData(
$data)
247 if (
$item->getIsVirtual() ||
$item->getLockedDoShip()) {
251 if (
$item->isDummy(
true)) {
252 if (
$item->getHasChildren()) {
253 if (
$item->isShipSeparately()) {
257 foreach (
$item->getChildrenItems() as $child) {
258 if ($child->getIsVirtual()) {
263 if ($child->getQtyToShip() > 0) {
267 if (isset(
$items[$child->getId()]) &&
$items[$child->getId()] > 0) {
275 $parent =
$item->getParentItem();
278 return $parent->getQtyToShip() > 0;
280 return isset(
$items[$parent->getId()]) &&
$items[$parent->getId()] > 0;
284 return $item->getQtyToShip() > 0;
295 if (
$item->getIsQtyDecimal()) {
301 return $qty > 0 ? $qty : 0;
create(\Magento\Sales\Model\Order $order, array $items=[], $tracks=null)
elseif(isset( $params[ 'redirect_parent']))
canShipItem($item, array $items=[])
prepareTracks(\Magento\Sales\Api\Data\ShipmentInterface $shipment, array $tracks)
__construct(\Magento\Sales\Model\Convert\OrderFactory $convertOrderFactory, \Magento\Sales\Model\Order\Shipment\TrackFactory $trackFactory, Json $serializer=null)
foreach($order->getItems() as $orderItem) $shipment