| Conditions | 5 |
| Paths | 8 |
| Total Lines | 39 |
| Code Lines | 29 |
| Lines | 11 |
| Ratio | 28.21 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public static function processData(ModificationDataEvent $event) |
||
| 13 | { |
||
| 14 | $url = htmlspecialchars(Url::toRoute(['@product', 'model' => $event->model])); |
||
| 15 | $image = htmlspecialchars($event->model->image->getOriginalUrl()); |
||
| 16 | View Code Duplication | if ($event->model->unlimited_count === 1) { |
|
| 17 | $inStock = 'in stock'; |
||
| 18 | } else { |
||
| 19 | $inStock = 'out of stock'; |
||
| 20 | foreach ($event->model->getWarehousesState() as $warehouse) { |
||
| 21 | if ($warehouse->in_warehouse > 0) { |
||
| 22 | $inStock = 'in stock'; |
||
| 23 | break; |
||
| 24 | } |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | $price = number_format( |
||
| 29 | CurrencyHelper::convertCurrencies($event->model->price, $event->model->currency, |
||
| 30 | $event->sender->mainCurrency), |
||
| 31 | 2, |
||
| 32 | '.', |
||
| 33 | '' |
||
| 34 | ) . ' ' . $event->sender->mainCurrency->iso_code; |
||
| 35 | |||
| 36 | $event->data = [ |
||
| 37 | 'title' => $event->model->name, |
||
| 38 | 'description' => $event->model->announce, |
||
| 39 | 'link' => $event->sender->host . $url, |
||
| 40 | 'g:id' => $event->model->id, |
||
| 41 | 'g:image_link' => $image, |
||
| 42 | 'g:condition' => 'new', |
||
| 43 | 'g:availability' => $inStock, |
||
| 44 | 'g:price' => $price |
||
| 45 | ]; |
||
| 46 | if ($event->model->parent_id !== 0) { |
||
| 47 | $event->data['g:item_group_id'] = $event->model->parent_id; |
||
| 48 | } |
||
| 49 | |||
| 50 | } |
||
| 51 | } |