#i','', $html)); $text = strip_tags($prepared); $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8'); $text = preg_replace('/\s+/u', ' ', trim($text)); if(function_exists('mb_strlen') && function_exists('mb_substr')) { if(mb_strlen($text, 'UTF-8') > $maxLen) { $text = mb_substr($text, 0, $maxLen, 'UTF-8'); } } else { if(strlen($text) > $maxLen) { $text = substr($text, 0, $maxLen); } } return $text; } } ?>getByName('hikashop','google_products'); $addCode = (empty($google_products->params['add_code'])) ? '0' : $google_products->params['add_code']; $inStockOnly = (empty($google_products->params['in_stock_only'])) ? '0' : $google_products->params['in_stock_only']; $taxedPrice = (empty($google_products->params['taxed_price'])) ? '0' : $google_products->params['taxed_price']; $noDiscount = (empty($google_products->params['no_discount'])) ? '0' : $google_products->params['no_discount']; $priceDisplayed = (empty($google_products->params['price_displayed'])) ? 'cheapest' : $google_products->params['price_displayed']; $includeVariants = (empty($google_products->params['include_variants'])) ? '0' : $google_products->params['include_variants']; $google_products_params = array(); $google_products_params['age_group'] = (empty($google_products->params['age_group'])) ? '' : $google_products->params['age_group']; $google_products_params['gender'] = (empty($google_products->params['gender'])) ? '' : $google_products->params['gender']; $google_products_params['size'] = (empty($google_products->params['size'])) ? '' : $google_products->params['size']; $google_products_params['color'] = (empty($google_products->params['color'])) ? '' : $google_products->params['color']; $google_products_params['mpn'] = (empty($google_products->params['mpn'])) ? '' : $google_products->params['mpn']; global $Itemid; $main =& $this->element; if(!empty($this->element->main)) { $main =& $this->element->main; } $hasStock = $main->product_quantity != 0; if (isset($this->element->variants) && $main->product_quantity == -1) { $hasStock = false; foreach ($this->element->variants as $key => $variant) { if ($variant->product_quantity != 0) { $hasStock = true; break; } } } if(($inStockOnly == '1') && !$hasStock) return; $mpn = ''; if($addCode == '1') $mpn = $main->product_code; $selected_price = $this->priceSelected($this->element, $priceDisplayed, $noDiscount, $taxedPrice); $config = hikashop_config(); $uploadFolder = ltrim(JPath::clean(html_entity_decode($config->get('uploadfolder'))),DS); $uploadFolder = rtrim($uploadFolder,DS).DS; $main_uploadFolder_url = str_replace(DS,'/',$uploadFolder); $img_tbl = array(); if (isset($main->images)) { foreach ($main->images as $key => $image) { $img_tbl[] = JURI::base().$main_uploadFolder_url.$image->file_path; } } if ($main->product_quantity == 0) $stock = "OutOfStock"; else $stock = "InStock"; if (!isset($this->element->variants)) { $product_id = $this->element->product_id; $product_type = 'Product'; } else { $product_id = $this->element->product_parent_id; $product_type = 'ProductGroup'; } $db = JFactory::getDBO(); $query = 'SELECT * FROM '.hikashop_table('vote').' WHERE vote_type = \'product\' AND vote_published > 0 AND vote_ref_id = '.(int)$product_id; $db->setQuery($query); $voteComments = $db->loadObjectList(); $config = hikashop_config(); $hikashop_vote_nb_star = $config->get('vote_star_number'); $bestRating = 0; $allRatingTot = 0; foreach ($voteComments as $k => $review) { if ($review->vote_rating > $bestRating) $bestRating = $review->vote_rating; $allRatingTot += $review->vote_rating; } $averageRating = 0; if (($allRatingTot != 0) && ((int)count($voteComments) != 0)) { $averageRating = round($allRatingTot / (int)count($voteComments), 2); } $type = '@type'; $reviewObject = array(); foreach ($voteComments as $k => $review) { $author_obj = new stdClass(); $author_obj->$type = "Person"; $author_obj->name = $review->vote_pseudo; $reviewRating_obj = new stdClass(); $reviewRating_obj->$type = "Rating"; $reviewRating_obj->ratingValue = $review->vote_rating; $reviewRating_obj->bestRating = $bestRating; $review_obj = new stdClass(); $review_obj->$type = "Review"; $review_obj->reviewRating = $reviewRating_obj; $review_obj->author = $author_obj; $review_obj->datePublished = date('m/d/Y H:i:s', $review->vote_date); $review_obj->reviewBody = $review->vote_comment; $reviewObject[] = $review_obj; } $type = '@type'; if (isset($this->manufacturer->category_name)) { $brand_obj = new stdClass(); $brand_obj->$type = "Brand"; $brand_obj->name = $this->manufacturer->category_name; } $aggregateRating_obj = new stdClass(); $aggregateRating_obj->$type = "AggregateRating"; $aggregateRating_obj->ratingValue = $averageRating; $aggregateRating_obj->reviewCount = (int)count($voteComments); $priceSpecification = new stdClass(); $priceSpecification->$type = "PriceSpecification"; $priceSpecification->price = $selected_price; $priceSpecification->priceCurrency = $this->currency->currency_code; $offer_obj = new stdClass(); $offer_obj->$type = "Offer"; $offer_obj->url = "https://www.example.com/trinket_offer"; $offer_obj->itemCondition = "https://schema.org/NewCondition"; $offer_obj->availability = "https://schema.org/".$stock; $offer_obj->priceSpecification = $priceSpecification; if ($product_type == 'Product' || $includeVariants == '0') { $obj = new stdClass(); $obj->context = "https://schema.org/"; $obj->$type = $product_type; $obj->productGroupID = (string)$main->product_code; $obj->name = strip_tags($main->product_name); $obj->image = $img_tbl; $description = JHTML::_('content.prepare',preg_replace('#