/** * Show star_rating * @param SProducts $item */ public function show_star_rating($item = null, $registerScript = true) { $get_settings = $this->rating_model->get_settings(); //prepare array with pages which can display "Star rating" $this->list_for_show = json_decode($get_settings['settings'], true); if ($this->list_for_show == null) { $this->list_for_show = array(); } $id = $this->core->core_data['id']; $type = $this->core->core_data['data_type']; // product rating if ($item != null && $item instanceof SProducts) { if ($item->getRating() != null) { $rating_s = (int) $item->getRating() * 20; } else { $rating_s = 0; } $data = array('id_type' => $item->getId(), 'type' => 'product', 'votes' => $item->getVotes(), 'rating' => $rating_s); $template = 'product_star_rating'; } else { if (in_array($type, array_keys($this->list_for_show))) { $rating = $this->rating_model->get_rating($id, $type); if ($rating->votes != 0) { $rating_s = $rating->rating / $rating->votes * 20; //rating in percent } else { $rating_s = 0; } $data = array('id' => $rating->id, 'type' => $rating->type, 'votes' => $rating->votes, 'rating' => $rating_s); $template = 'star_rating'; } else { $template = null; return false; } } //Show template with prepared parametrs if ($template !== null) { $renderTemplate = CMSFactory\assetManager::create(); } $renderTemplate->setData($data)->registerStyle('style'); // if ($template != 'product_star_rating')$registerScript if ($registerScript) { $renderTemplate->registerScript('scripts'); } $renderTemplate->render($template, true); return $this; }
/** * * @param SProducts $product * @return array */ private function getAdditionalImages(SProducts $product) { $offers = array(); $images = $iterator = $offers = null; $images = $product->getSProductImagess(); if (count($images) > 0 && ++$iterator < 9) { foreach ($images as $key => $image) { $offers[] = productImageUrl('products/additional/' . $image->getImageName()); } } return $offers; }