Commit 15f3892a27542f8a01ee86a28ff103709d8d6566
1 parent
105e64fb
tab
Showing
2 changed files
with
24 additions
and
16 deletions
Show diff stats
src/app/frontend/controllers/AjaxController.php
| @@ -11,41 +11,50 @@ class AjaxController extends \controllers\ControllerBase | @@ -11,41 +11,50 @@ class AjaxController extends \controllers\ControllerBase | ||
| 11 | { | 11 | { |
| 12 | /////////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////////// |
| 13 | 13 | ||
| 14 | - public function getItemsAction( ) | ||
| 15 | - { | 14 | + public function getItemsAction() { |
| 15 | + | ||
| 16 | header('Content-Type: application/json; charset=utf8'); | 16 | header('Content-Type: application/json; charset=utf8'); |
| 17 | - | ||
| 18 | - $term = $this->request->getPost('term', 'string', '' ); | ||
| 19 | 17 | ||
| 20 | - $items_ = $this->models->getItems()->getItemsByTermFromCatalog( $term, 'items_dropdown', 1, $this->lang_id ); | 18 | + $term = $this->request->getPost('term', 'string', ''); |
| 19 | + | ||
| 20 | + $items_ = $this->models->getItems()->getItemsByTermFromCatalog($term, 'items_dropdown', 1, $this->lang_id); | ||
| 21 | + | ||
| 21 | if(!$items_) { | 22 | if(!$items_) { |
| 22 | - $items_ = $this->models->getItems()->getItemsByTerm( $term, 'items_dropdown', 1, $this->lang_id ); | 23 | + |
| 24 | + $items_ = $this->models->getItems()->getItemsByTerm($term, 'items_dropdown', 1, $this->lang_id); | ||
| 25 | + | ||
| 23 | } | 26 | } |
| 24 | 27 | ||
| 25 | - $items = []; | ||
| 26 | - if( !empty( $items_ ) ) | ||
| 27 | - { | ||
| 28 | - $items_ids = $this->common->array_column( $items_, 'item_id' ); | 28 | + $items = []; |
| 29 | + | ||
| 30 | + if(!empty($items_)) { | ||
| 31 | + | ||
| 32 | + $items_ids = $this->common->array_column($items_, 'item_id'); | ||
| 29 | 33 | ||
| 30 | //discount | 34 | //discount |
| 31 | $discount = $this->models->getDiscount()->getActiveData(); | 35 | $discount = $this->models->getDiscount()->getActiveData(); |
| 32 | $discount = $this->models->getDiscount()->explodeGroupIds($discount); | 36 | $discount = $this->models->getDiscount()->explodeGroupIds($discount); |
| 33 | $discount = $discount[0]; | 37 | $discount = $discount[0]; |
| 34 | 38 | ||
| 35 | - $items = $this->models->getItems()->getItemsByIds( $this->lang_id, $items_ids ); | ||
| 36 | - foreach( $items as &$i ) | ||
| 37 | - { | 39 | + $items = $this->models->getItems()->getItemsByIds( $this->lang_id, $items_ids ); |
| 38 | 40 | ||
| 39 | - $i['cover'] = !empty( $i['group_cover'] ) ? $this->storage->getPhotoUrl( $i['group_cover'], 'avatar', '200x' ) : '/images/packet.jpg'; | ||
| 40 | - $i['alias'] = $this->seoUrl->setUrl($this->url->get([ 'for' => 'item', 'subtype' => $i['catalog_alias'], 'group_alias' => $i['group_alias'], 'item_id' => $i['id'] ])); | 41 | + foreach($items as &$i) { |
| 42 | + | ||
| 43 | + $i['cover'] = !empty( $i['group_cover'] ) ? $this->storage->getPhotoUrl( $i['group_cover'], 'avatar', '200x' ) : '/images/packet.jpg'; | ||
| 44 | + $i['alias'] = $this->seoUrl->setUrl($this->url->get([ 'for' => 'item', 'subtype' => $i['catalog_alias'], 'group_alias' => $i['group_alias'], 'item_id' => $i['id'] ])); | ||
| 41 | 45 | ||
| 42 | if ($discount['discount'] > 0 && $discount['discount'] <= 100 && in_array($i['id'], $discount['group_ids'])) { | 46 | if ($discount['discount'] > 0 && $discount['discount'] <= 100 && in_array($i['id'], $discount['group_ids'])) { |
| 47 | + | ||
| 43 | $i['discounted_price'] = round($i['price2']*(1-$discount['discount']/100), 1); | 48 | $i['discounted_price'] = round($i['price2']*(1-$discount['discount']/100), 1); |
| 49 | + | ||
| 44 | } | 50 | } |
| 51 | + | ||
| 45 | } | 52 | } |
| 53 | + | ||
| 46 | } | 54 | } |
| 47 | 55 | ||
| 48 | die( json_encode( $items ) ); | 56 | die( json_encode( $items ) ); |
| 57 | + | ||
| 49 | } | 58 | } |
| 50 | 59 | ||
| 51 | 60 |
src/app/frontend/controllers/MenuController.php
| @@ -421,7 +421,6 @@ class MenuController extends \controllers\ControllerBase | @@ -421,7 +421,6 @@ class MenuController extends \controllers\ControllerBase | ||
| 421 | } | 421 | } |
| 422 | 422 | ||
| 423 | //discount | 423 | //discount |
| 424 | - | ||
| 425 | $discount = $this->models->getDiscount()->getActiveData(); | 424 | $discount = $this->models->getDiscount()->getActiveData(); |
| 426 | if (!empty($discount)) { | 425 | if (!empty($discount)) { |
| 427 | $discount = $discount[0]; | 426 | $discount = $discount[0]; |