本文整理汇总了PHP中Image::getCover方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::getCover方法的具体用法?PHP Image::getCover怎么用?PHP Image::getCover使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image::getCover方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateImageLink
protected static function generateImageLink($product, $ps_product, $id_lang, $iso_code)
{
$link = new Link();
$cover = Image::getCover($ps_product->id);
$product->{"image_link_small_{$iso_code}"} = $link->getImageLink($ps_product->link_rewrite[$id_lang], $cover["id_image"], ImageType::getFormatedName("small"));
$product->{"image_link_large_{$iso_code}"} = $link->getImageLink($ps_product->link_rewrite[$id_lang], $cover["id_image"], ImageType::getFormatedName("large"));
return $product;
}
示例2: formatProduct
protected function formatProduct($id_product, $id_lang)
{
$link = new Link();
$product = new Product($id_product, true, $id_lang);
$category = new Category($product->id_category_default, $id_lang);
$product->objectID = $product->id;
$product->category = $category->name;
$product->url = $link->getProductLink($product->id);
/* Cover */
$cover = Image::getCover($product->id);
$product->image_link_small = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('small'));
$product->image_link_large = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('large'));
return $product;
}
示例3: renderList
public function renderList($id_wishlist)
{
$wishlist = new WishList($id_wishlist);
$products = WishList::getProductByIdCustomer($id_wishlist, $wishlist->id_customer, $this->context->language->id);
foreach ($products as $key => $val) {
$image = Image::getCover($val['id_product']);
$products[$key]['image'] = $this->context->link->getImageLink($val['link_rewrite'], $image['id_image'], ImageType::getFormatedName('small'));
}
$fields_list = array('image' => array('title' => $this->l('Image'), 'type' => 'image'), 'name' => array('title' => $this->l('Product'), 'type' => 'text'), 'attributes_small' => array('title' => $this->l('Combination'), 'type' => 'text'), 'quantity' => array('title' => $this->l('Quantity'), 'type' => 'text'), 'priority' => array('title' => $this->l('Priority'), 'type' => 'priority', 'values' => array($this->l('High'), $this->l('Medium'), $this->l('Low'))));
$helper = new HelperList();
$helper->shopLinkType = '';
$helper->simple_header = true;
$helper->no_link = true;
$helper->actions = array('view');
$helper->show_toolbar = false;
$helper->module = $this;
$helper->identifier = 'id_product';
$helper->title = $this->l('Product list');
$helper->table = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
$helper->tpl_vars = array('priority' => array($this->l('High'), $this->l('Medium'), $this->l('Low')));
return $helper->generateList($products, $fields_list);
}
示例4: save
public function save()
{
$product = new Product($_GET['id_product']);
if (!Validate::isLoadedObject($product)) {
return array('error' => Tools::displayError('Cannot add image because product creation failed.'));
} else {
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
$legends = Tools::getValue('legend');
if (is_array($legends)) {
foreach ($legends as $key => $legend) {
if (Validate::isGenericName($legend)) {
$image->legend[(int) $key] = $legend;
} else {
return array('error' => sprintf(Tools::displayError('Error on image caption: "%1s" is not a valid caption.'), Tools::safeOutput($legend)));
}
}
}
if (!Image::getCover($image->id_product)) {
$image->cover = 1;
} else {
$image->cover = 0;
}
if (($validate = $image->validateFieldsLang(false, true)) !== true) {
return array('error' => Tools::displayError($validate));
}
if (!$image->add()) {
return array('error' => Tools::displayError('Error while creating additional image'));
} else {
return $this->copyImage($product->id, $image->id);
}
}
}
示例5: ajaxProcessDeleteProductImage
public function ajaxProcessDeleteProductImage()
{
$this->display = 'content';
$res = true;
/* Delete product image */
$image = new Image((int) Tools::getValue('id_image'));
$this->content['id'] = $image->id;
$res &= $image->delete();
// if deleted image was the cover, change it to the first one
if (!Image::getCover($image->id_product)) {
$res &= Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'image_shop` image_shop, ' . _DB_PREFIX_ . 'image i
SET image_shop.`cover` = 1,
i.cover = 1
WHERE image_shop.`id_image` = (SELECT id_image FROM
(SELECT image_shop.id_image
FROM ' . _DB_PREFIX_ . 'image i' . Shop::addSqlAssociation('image', 'i') . '
WHERE i.id_product =' . (int) $image->id_product . ' LIMIT 1
) tmpImage)
AND id_shop=' . (int) $this->context->shop->id . '
AND i.id_image = image_shop.id_image
');
}
if (file_exists(_PS_TMP_IMG_DIR_ . 'product_' . $image->id_product . '.jpg')) {
$res &= @unlink(_PS_TMP_IMG_DIR_ . 'product_' . $image->id_product . '.jpg');
}
if (file_exists(_PS_TMP_IMG_DIR_ . 'product_mini_' . $image->id_product . '_' . $this->context->shop->id . '.jpg')) {
$res &= @unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . $image->id_product . '_' . $this->context->shop->id . '.jpg');
}
if ($res) {
$this->jsonConfirmation($this->_conf[7]);
} else {
$this->jsonError(Tools::displayError('An error occurred while attempting to delete the product image.'));
}
}
示例6: initContent
public function initContent()
{
include _PS_MODULE_DIR_ . 'blocksearch_mod' . DIRECTORY_SEPARATOR . 'IqitSearch.php';
$query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
$original_query = Tools::getValue('q');
$search_query_cat = (int) Tools::getValue('search_query_cat');
if ($this->ajax_search) {
self::$link = new Link();
$image = new Image();
$searchResults = IqitSearch::find((int) Tools::getValue('id_lang'), $query, $search_query_cat, 1, 10, 'position', 'desc', true);
$taxes = Product::getTaxCalculationMethod();
$currency = (int) Context::getContext()->currency->id;
$iso_code = $this->context->language->iso_code;
if (is_array($searchResults)) {
foreach ($searchResults as &$product) {
$imageID = $image->getCover($product['id_product']);
if (isset($imageID['id_image'])) {
$imgLink = $this->context->link->getImageLink($product['prewrite'], (int) $product['id_product'] . '-' . $imageID['id_image'], 'small_default');
} else {
$imgLink = _THEME_PROD_DIR_ . $iso_code . "-default-small_default.jpg";
}
$product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
$product['obr_thumb'] = $imgLink;
$product['product_price'] = Product::getPriceStatic((int) $product['id_product'], false, NULL, 2);
if ($taxes == 0 or $taxes == 2) {
$product['product_price'] = Tools::displayPrice(Product::getPriceStatic((int) $product['id_product'], true), $currency);
} elseif ($taxes == 1) {
$product['product_price'] = Tools::displayPrice(Product::getPriceStatic((int) $product['id_product'], false), $currency);
}
}
}
$this->ajaxDie(Tools::jsonEncode($searchResults));
}
// Only controller content initialization when the user use the normal search
parent::initContent();
if ($this->instant_search && !is_array($query)) {
$this->productSort();
$this->n = abs((int) Tools::getValue('n', $product_per_page));
$this->p = abs((int) Tools::getValue('p', 1));
$search = IqitSearch::find($this->context->language->id, $query, $search_query_cat, 1, 10, 'position', 'desc');
Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
$nbProducts = $search['total'];
$this->pagination($nbProducts);
$this->addColorsToProductList($search['result']);
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < $nbProducts; $i++) {
if (isset($search['result'][$i]['id_product'])) {
$image_array[$search['result'][$i]['id_product']] = Product::getProductsImgs($search['result'][$i]['id_product']);
}
}
$this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
}
$this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
} elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
$this->productSort();
$this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
$this->p = abs((int) Tools::getValue('p', 1));
$original_query = $query;
$query = Tools::replaceAccentedChars(urldecode($query));
$search = IqitSearch::find($this->context->language->id, $query, $search_query_cat, $this->p, $this->n, $this->orderBy, $this->orderWay);
if (is_array($search['result'])) {
foreach ($search['result'] as &$product) {
$product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
}
}
Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
$nbProducts = $search['total'];
$this->pagination($nbProducts);
$this->addColorsToProductList($search['result']);
/************************* /Images Array ******************************/
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < $nbProducts; $i++) {
if (isset($search['result'][$i]['id_product'])) {
$image_array[$search['result'][$i]['id_product']] = Product::getProductsImgs($search['result'][$i]['id_product']);
}
}
$this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
}
/************************* /Images Array ******************************/
$this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
} elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
$nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
$this->pagination($nbProducts);
$result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
$this->addColorsToProductList($result);
/************************* /Images Array ******************************/
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < $nbProducts; $i++) {
if (isset($result[$i]['id_product'])) {
$image_array[$result[$i]['id_product']] = Product::getProductsImgs($result[$i]['id_product']);
}
}
$this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
}
/************************* /Images Array ******************************/
$this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
//.........这里部分代码省略.........
示例7: getPictures
function getPictures($prod_id, $link_rewrite)
{
$link = $this->context->link;
$cover = Image::getCover($prod_id);
$cover_picture = $link->getImageLink($link_rewrite, $prod_id . '-' . $cover['id_image'], $this->image_type);
$pictures = array($cover_picture);
$images = Image::getImages($this->id_lang, $prod_id);
foreach ($images as $image) {
if ($image['id_image'] != $cover['id_image']) {
$picture = $link->getImageLink($link_rewrite, $prod_id . '-' . $image['id_image'], $this->image_type);
$pictures[] = $picture;
}
}
return array_slice($pictures, 0, 10);
}
示例8: save
public function save()
{
$product = new Product($_GET['id_product']);
if (!Validate::isLoadedObject($product)) {
return array('error' => Tools::displayError('Cannot add image because product creation failed.'));
} else {
$image = new Image();
$image->id_product = (int) $product->id;
$image->position = Image::getHighestPosition($product->id) + 1;
if (!Image::getCover($image->id_product)) {
$image->cover = 1;
} else {
$image->cover = 0;
}
if (!$image->add()) {
return array('error' => Tools::displayError('Error while creating additional image'));
} else {
return $this->copyImage($product->id, $image->id);
}
}
}
示例9: ajaxProcessDeleteProductImage
function ajaxProcessDeleteProductImage()
{
${${"GLOBALS"}["gyrslyepsx"]} = true;
${"GLOBALS"}["mkyfovtt"] = "json";
$rxlcerg = "res";
${${"GLOBALS"}["jjqqyxpkvq"]} = new Image((int) Tools::getValue("id_image"));
${$rxlcerg} &= $image->delete();
if (!Image::getCover($image->id_product)) {
${${"GLOBALS"}["gyrslyepsx"]} &= Db::getInstance()->execute("\n\t\t\tUPDATE `" . _DB_PREFIX_ . "image`\n\t\t\tSET `cover` = 1\n\t\t\tWHERE `id_product` = " . (int) $image->id_product . " LIMIT 1");
}
if (file_exists(_PS_TMP_IMG_DIR_ . "product_" . $image->id_product . ".jpg")) {
${${"GLOBALS"}["gyrslyepsx"]} &= @unlink(_PS_TMP_IMG_DIR_ . "product_" . $image->id_product . ".jpg");
}
$ibipyme = "json";
if (file_exists(_PS_TMP_IMG_DIR_ . "product_mini_" . $image->id_product . ".jpg")) {
${${"GLOBALS"}["gyrslyepsx"]} &= @unlink(_PS_TMP_IMG_DIR_ . "product_mini_" . $image->id_product . ".jpg");
}
if (${${"GLOBALS"}["gyrslyepsx"]}) {
${$ibipyme} = array("status" => "ok", "content" => array("id" => $image->id), "message" => "");
} else {
${${"GLOBALS"}["mkyfovtt"]} = array("status" => "error", "message" => Tools::displayError("Error on deleting product image"));
}
return Tools::jsonEncode(${${"GLOBALS"}["pthyxux"]});
}
示例10: hookFooter
/**
* Return the rich snippet code to the hook footer in front office if configurated
*
* Case 1: Return rich snippet code if configurated
* Case 2: Return '' if not configurated or if the product are no reviews
*
* @return tpl string in hook footer
*/
public function hookFooter()
{
global $smarty, $cookie;
if (Configuration::get('AV_MULTILINGUE') == 'checked') {
$this->id_lang = $this->context->language->id;
$this->iso_lang = pSQL(Language::getIsoById($this->id_lang));
$this->group_name = $this->getIdConfigurationGroup($this->iso_lang);
}
$id_product = (int) Tools::getValue('id_product');
if (empty($id_product)) {
return '';
}
$o_av = new NetReviewsModel();
$stats_product = !isset($this->stats_product) || empty($this->stats_product) ? $o_av->getStatsProduct($id_product, $this->group_name, $this->context->shop->getContextShopID()) : $this->stats_product;
if ($stats_product['nb_reviews'] == 0) {
return '';
}
$lang_id = (int) $this->context->language->id;
if (empty($lang_id)) {
$lang_id = 1;
}
$product = new Product((int) $id_product);
$link = new LinkCore();
$a_image = Image::getCover($id_product);
$smarty->assign(array('count_reviews' => $stats_product['nb_reviews'], 'average_rate' => round($stats_product['rate'], 1), 'average_rate_percent' => $stats_product['rate'] * 20, 'product_name' => $this->getProductName($id_product, $lang_id), 'product_description' => $product->description_short[$lang_id], 'product_price' => $product->getPrice(true, null, 2), 'product_quantity' => $product->quantity, 'url_image' => !empty($a_image) ? $link->getImageLink($product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')], $id_product . '-' . $a_image['id_image']) : ''));
if (version_compare(_PS_VERSION_, '1.5', '>') && ($return = $this->display(__FILE__, '/views/templates/hook/footer_av.tpl')) || version_compare(_PS_VERSION_, '1.5', '<') && ($return = $this->display(__FILE__, 'footer_av.tpl'))) {
return $return;
} else {
return '';
}
}
示例11: ajaxProcessDeleteProductImage
public function ajaxProcessDeleteProductImage()
{
$this->display = 'content';
$res = true;
/* Delete product image */
$image = new Image((int) Tools::getValue('id_image'));
$this->content['id'] = $image->id;
$res &= $image->delete();
// if deleted image was the cover, change it to the first one
if (!Image::getCover($image->id_product)) {
$res &= Db::getInstance()->execute('
UPDATE `' . _DB_PREFIX_ . 'image`
SET `cover` = 1
WHERE `id_product` = ' . (int) $image->id_product . ' LIMIT 1');
}
if (file_exists(_PS_TMP_IMG_DIR_ . 'product_' . $image->id_product . '.jpg')) {
$res &= @unlink(_PS_TMP_IMG_DIR_ . 'product_' . $image->id_product . '.jpg');
}
if (file_exists(_PS_TMP_IMG_DIR_ . 'product_mini_' . $image->id_product . '.jpg')) {
$res &= @unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . $image->id_product . '.jpg');
}
if ($res) {
$this->jsonConfirmation($this->_conf[7]);
} else {
$this->jsonError(Tools::displayError('Error on deleting product image'));
}
}
示例12: prepareCartQuote
//.........这里部分代码省略.........
/** @noinspection PhpUndefinedFieldInspection */
$user_country = new Country($address->id_country);
$shipping_addr = $quote->getShippingAddress();
$shipping_addr->setCustomerAddressId($this->context->cart->id_address_delivery);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setFirstname($address->firstname);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setLastname($address->lastname);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setCompany($address->company);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setStreet1($address->address1);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setStreet2($address->address2);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setCity($address->city);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setCountry($user_country->iso_code);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setCountryState($user_state->name);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setPostcode($address->postcode);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setTelephone1($address->phone);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setTelephone2($address->phone_mobile);
/** @noinspection PhpUndefinedFieldInspection */
$shipping_addr->setTaxVATNumber($address->vat_number);
// products
if ($products) {
foreach ($products as $product) {
/** @noinspection PhpUndefinedClassInspection */
$link = new Link();
/** @noinspection PhpUndefinedMethodInspection */
$url = $link->getProductLink($product);
/** @noinspection PhpUndefinedClassInspection */
/** @noinspection PhpUndefinedMethodInspection */
$image = Image::getCover($product['id_product']);
/** @noinspection PhpUndefinedMethodInspection */
$imagePath = $image ? $link->getImageLink($product['link_rewrite'], $image['id_image'], 'home_default') : null;
$imagePath = $imagePath ? 'http://' . $imagePath : $imagePath;
/** @var \Payin7\Models\OrderItemModel $pm */
$pm = $this->getModelInstance('order_item');
$pm->setId($product['id_product']);
$pm->setProductId($product['id_product']);
$pm->setName($product['name']);
$pm->setProductUrl($url);
$pm->setImageUrl($imagePath);
$pm->setShortDescription(isset($product['description_short']) ? $product['description_short'] : null);
$pm->setFullDescription(isset($product['attributes']) ? $product['attributes'] : null);
$pm->setIsVirtual(isset($product['is_virtual']) ? $product['is_virtual'] : null);
$pm->setQtyOrdered($product['cart_quantity']);
$pm->setPriceInclTax($this->roundPrice($product['price_wt']));
$pm->setPrice($this->roundPrice($product['price']));
$pm->setTaxAmount($product['price_wt'] - $product['price']);
$pm->setPriceBeforeDiscount($this->roundPrice(isset($product['price_without_reduction']) ? $product['price_without_reduction'] : null));
$pm->setDiscountAmount($this->roundPrice(isset($product['price_with_reduction_without_tax']) ? $product['price_with_reduction_without_tax'] : null));
$pm->setDiscountAmountWithTax($this->roundPrice(isset($product['price_with_reduction']) ? $product['price_with_reduction'] : null));
$pm->setShippingAmountWithTax($this->roundPrice(isset($product['additional_shipping_cost']) ? $product['additional_shipping_cost'] : null));
$pm->setShippingAmount($this->roundPrice($pm->getShippingAmountWithTax()));
$pm->setRowTotal($this->roundPrice($product['price']));
$pm->setRowTotalInclTax($this->roundPrice($product['price_wt']));
$pm->setTaxRate(isset($product['rate']) ? $product['rate'] : null);
$quote->addItem($pm);
unset($product);
}
}
// customer
/** @noinspection PhpUndefinedClassInspection */
$cust = new Customer($cart->id_customer);
/** @noinspection PhpUndefinedClassInspection */
$custlang = new Language($cart->id_lang);
/** @noinspection PhpUndefinedFieldInspection */
$gender = $cust->id_gender == 1 ? \Payin7\Models\CustomerModel::GENDER_MALE : ($cust->id_gender == 2 ? \Payin7\Models\CustomerModel::GENDER_FEMALE : null);
/** @var \Payin7\Models\CustomerModel $customer */
$customer = $this->getModelInstance('customer');
$customer->setCustomerId($cart->id_customer);
$customer->setGender($gender);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setPreferredLanguageCode($custlang->iso_code);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setCreatedAt($cust->date_add);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setUpdatedAt($cust->date_upd);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setDob($cust->birthday);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setEmail($cust->email);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setFirstName($cust->firstname);
/** @noinspection PhpUndefinedFieldInspection */
$customer->setLastName($cust->lastname);
// missing on 1.4
if (property_exists($cust, 'company')) {
/** @noinspection PhpUndefinedFieldInspection */
$customer->setCompany($cust->company);
}
$quote->setCustomer($customer);
return $quote;
}
示例13: getProductImage
/**
* getProductImage() method returns product image
*
* @param obj $oProduct
* @param string $sImageType
* @return obj
*/
public static function getProductImage(Product &$oProduct, $sImageType)
{
$sImgUrl = '';
if (Validate::isLoadedObject($oProduct)) {
// use case - get Image
$aImage = Image::getCover($oProduct->id);
if (!empty($aImage)) {
// get image url
$sImgUrl = self::getLinkObj()->getImageLink($oProduct->link_rewrite, $oProduct->id . '-' . $aImage['id_image'], $sImageType);
// use case - get valid IMG URI before Prestashop 1.4
$sImgUrl = self::detectHttpUri($sImgUrl);
}
}
return $sImgUrl;
}
示例14: getProductImageLink
/**
* @param \Product $product
*
* @return string
* @throws \Exception
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @since 150213
*/
protected function getProductImageLink(\Product &$product)
{
$link = new \Link();
$imageLink = null;
if ($this->Options->getValue('map_image') == 1) {
$images = $product->getImages($this->defaultLang);
if (!empty($images)) {
shuffle($images);
$imageLink = $link->getImageLink($product->link_rewrite, end($images)['id_image']);
}
} else {
$coverImage = \Image::getCover($product->id);
if ($coverImage && !empty($coverImage) && isset($coverImage['id_image'])) {
$imageLink = $link->getImageLink($product->link_rewrite, $coverImage['id_image']);
}
}
return empty($imageLink) ? '' : urldecode($this->addHttp($imageLink));
}
示例15: getUrlsProduct
public static function getUrlsProduct($product_id)
{
$product_exist = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'product WHERE id_product =' . (int) $product_id);
if ($product_exist) {
$o_product = new Product($product_id, false, (int) Configuration::get('PS_LANG_DEFAULT'));
$protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
$use_ssl = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
$protocol_content = $use_ssl ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
$id_cover_image = Image::getCover($product_id);
$image_path = $link->getImageLink($o_product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')], $id_cover_image['id_image']);
$url_product = $link->getProductLink($product_id);
return array('url_product' => $url_product, 'url_image_product' => $image_path);
}
}