@@ -80,11 +80,13 @@ discard block |
||
| 80 | 80 | $order = $orderProduct->getOrder(); |
| 81 | 81 | $product = $orderProduct->getProduct(); |
| 82 | 82 | |
| 83 | - if ($order->getOrderType() == 'sale' && !$orderProduct->getOutInventory()) |
|
| 84 | - $orderProduct->setOutInventory($product->getDefaultOutInventory()); |
|
| 83 | + if ($order->getOrderType() == 'sale' && !$orderProduct->getOutInventory()) { |
|
| 84 | + $orderProduct->setOutInventory($product->getDefaultOutInventory()); |
|
| 85 | + } |
|
| 85 | 86 | |
| 86 | - if ($order->getOrderType() == 'purchase' && !$orderProduct->getInInventory()) |
|
| 87 | - $orderProduct->setInInventory($product->getDefaultInInventory()); |
|
| 87 | + if ($order->getOrderType() == 'purchase' && !$orderProduct->getInInventory()) { |
|
| 88 | + $orderProduct->setInInventory($product->getDefaultInInventory()); |
|
| 89 | + } |
|
| 88 | 90 | } |
| 89 | 91 | |
| 90 | 92 | private function checkSubproducts(OrderProduct $orderProduct) |
@@ -108,7 +110,9 @@ discard block |
||
| 108 | 110 | |
| 109 | 111 | public function postPersist(OrderProduct $orderProduct) |
| 110 | 112 | { |
| 111 | - if (!self::$mainProduct || !$this->request) return; |
|
| 113 | + if (!self::$mainProduct || !$this->request) { |
|
| 114 | + return; |
|
| 115 | + } |
|
| 112 | 116 | self::$mainProduct = false; |
| 113 | 117 | |
| 114 | 118 | $this->checkSubproducts($orderProduct); |
@@ -120,7 +124,9 @@ discard block |
||
| 120 | 124 | public function preRemove(OrderProduct $orderProduct) |
| 121 | 125 | { |
| 122 | 126 | |
| 123 | - if (!self::$mainProduct) return; |
|
| 127 | + if (!self::$mainProduct) { |
|
| 128 | + return; |
|
| 129 | + } |
|
| 124 | 130 | self::$mainProduct = false; |
| 125 | 131 | $order = $orderProduct->getOrder(); |
| 126 | 132 | $this->manager->persist($order->setPrice(0)); |
@@ -129,8 +135,9 @@ discard block |
||
| 129 | 135 | 'parentProduct' => $orderProduct->getProduct(), |
| 130 | 136 | ]); |
| 131 | 137 | |
| 132 | - foreach ($parentProducts as $parentProduct) |
|
| 133 | - $this->manager->remove($parentProduct); |
|
| 138 | + foreach ($parentProducts as $parentProduct) { |
|
| 139 | + $this->manager->remove($parentProduct); |
|
| 140 | + } |
|
| 134 | 141 | $this->manager->flush(); |
| 135 | 142 | |
| 136 | 143 | self::$calculateBefore[] = $order; |