本文整理汇总了PHP中ProductSale::getBestSales方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductSale::getBestSales方法的具体用法?PHP ProductSale::getBestSales怎么用?PHP ProductSale::getBestSales使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductSale
的用法示例。
在下文中一共展示了ProductSale::getBestSales方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process()
{
$this->productSort();
$nbProducts = (int) ProductSale::getNbSales();
$this->pagination($nbProducts);
self::$smarty->assign(array('products' => ProductSale::getBestSales((int) self::$cookie->id_lang, (int) $this->p - 1, (int) $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home')));
}
示例2: initContent
public function initContent()
{
if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
parent::initContent();
$this->productSort();
$nb_products = (int) ProductSale::getNbSales();
$this->pagination($nb_products);
if (!Tools::getValue('orderby')) {
$this->orderBy = 'sales';
}
$products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
$this->addColorsToProductList($products);
/************************* /Images Array ******************************/
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < $nb_products; $i++) {
if (isset($products[$i]['id_product'])) {
$image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$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' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
} else {
Tools::redirect('index.php?controller=404');
}
}
示例3: initContent
public function initContent()
{
parent::initContent();
$this->productSort();
$nbProducts = (int) ProductSale::getNbSales();
$this->pagination($nbProducts);
$this->context->smarty->assign(array('products' => ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home_default'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
}
示例4: initContent
public function initContent()
{
if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
parent::initContent();
$this->productSort();
$nbProducts = (int) ProductSale::getNbSales();
$this->pagination($nbProducts);
$products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
$this->addColorsToProductList($products);
$this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
} else {
Tools::redirect('index.php?controller=404');
}
}
示例5: renderContent
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array('name' => '', 'html' => '');
$setting = array_merge($t, $setting);
$setting['special'] = array();
$setting['bestseller'] = array();
$setting['featured'] = array();
$setting['newproducts'] = array();
$category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id);
$nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6;
$orderby = $setting['orderby'] ? $setting['orderby'] : 'position';
$orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC';
$items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3;
$columns_page = $setting['columns'] ? (int) $setting['columns'] : 3;
$interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000;
if ($setting['featured_display'] && $setting['featured_display'] == 1) {
$pro_featured = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
Context::getContext()->controller->addColorsToProductList($pro_featured);
$setting['featured'] = $pro_featured;
}
if ($setting['newarrivals_display'] && $setting['newarrivals_display'] == 1) {
$pro_newproducts = Product::getNewProducts((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway);
Context::getContext()->controller->addColorsToProductList($pro_newproducts);
$setting['newproducts'] = $pro_newproducts;
}
if ($setting['special_display'] && $setting['special_display'] == 1) {
$pro_special = Product::getPricesDrop((int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway);
Context::getContext()->controller->addColorsToProductList($pro_special);
$setting['special'] = $pro_special;
}
if ($setting['bestseller_display'] && $setting['bestseller_display'] == 1) {
$pro_bestseller = ProductSale::getBestSales((int) Context::getContext()->language->id, 0, $nb, $orderby, $orderway);
Context::getContext()->controller->addColorsToProductList($pro_bestseller);
$setting['bestseller'] = $pro_bestseller;
}
$setting['itemsperpage'] = $items_page;
$setting['columnspage'] = $columns_page;
$setting['interval'] = $interval;
$setting['scolumn'] = 12 / $columns_page;
$setting['homeSize'] = Image::getSize(ImageType::getFormatedName('home'));
$setting['myTab'] = 'leoproducttab' . rand(20, rand());
$output = array('type' => 'producttabs', 'data' => $setting);
return $output;
}
示例6: initContent
public function initContent()
{
if (Configuration::get('PS_DISPLAY_BEST_SELLERS')) {
parent::initContent();
$this->productSort();
$nbProducts = (int) ProductSale::getNbSales();
$this->pagination($nbProducts);
$products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
$this->addColorsToProductList($products);
$this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
if ($this->ajax) {
$product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
$pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
$nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
$nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
die;
} else {
$this->setTemplate(_PS_THEME_DIR_ . 'best-sales.tpl');
}
} else {
Tools::redirect('index.php?controller=404');
}
}
示例7: dirname
<?php
include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/header.php';
include dirname(__FILE__) . '/product-sort.php';
$nbProducts = intval(ProductSale::getNbSales());
include dirname(__FILE__) . '/pagination.php';
$smarty->assign(array('products' => ProductSale::getBestSales(intval($cookie->id_lang), intval($p) - 1, intval($n), $orderBy, $orderWay), 'nbProducts' => $nbProducts));
$smarty->display(_PS_THEME_DIR_ . 'best-sales.tpl');
include dirname(__FILE__) . '/footer.php';
示例8: hookHome
public function hookHome($params)
{
if (Configuration::get('PS_CATALOG_MODE')) {
return;
}
$currency = new Currency($params['cookie']->id_currency);
$bestsellers = ProductSale::getBestSales((int) $params['cookie']->id_lang, 0, 10);
if (!$bestsellers && !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) {
return;
}
$best_sellers = array();
if ($bestsellers) {
foreach ($bestsellers as $bestseller) {
$bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int) $bestseller['id_product']), $currency);
$best_sellers[] = $bestseller;
}
}
$this->smarty->assign(array('best_sellers' => $best_sellers, 'homeSize' => Image::getSize('home_default')));
return $this->display(__FILE__, 'blockbestsellers-home.tpl');
}
示例9: parseTemplateCategory
//.........这里部分代码省略.........
$productImagesData[$p_key]['link'] = '';
}
$productImagesData[$p_key]['title'] = $product['name'];
$productImagesData[$p_key]['thumb'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], 'small');
if ($tool->type == 'circle') {
$productImagesData[$p_key]['medium'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image'));
$productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('large-image'));
} else {
$productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image'));
}
}
$magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => "blockspecialsMagicZoomPlus"));
$pattern = '<ul[^>]*?>.*?<\\/ul>';
$output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output);
break;
case 'blockviewed':
$productsViewed = $GLOBALS['magictoolbox']['magiczoomplus']['productsViewed'];
$pCount = count($productsViewed);
if (!$pCount) {
break;
}
$GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true;
$productImagesData = array();
$useLink = !$tool->params->checkValue('link-to-product-page', 'No');
foreach ($productsViewed as $id_product) {
$productViewedObj = new Product(intval($id_product), false, intval($cookie->id_lang));
if (!Validate::isLoadedObject($productViewedObj) or !$productViewedObj->active) {
continue;
} else {
$images = $productViewedObj->getImages(intval($cookie->id_lang));
foreach ($images as $image) {
if ($image['cover']) {
$productViewedObj->cover = $productViewedObj->id . '-' . $image['id_image'];
$productViewedObj->legend = $image['legend'];
break;
}
}
if (!isset($productViewedObj->cover)) {
$productViewedObj->cover = Language::getIsoById($cookie->id_lang) . '-default';
$productViewedObj->legend = '';
}
$lrw = $productViewedObj->link_rewrite;
if ($useLink && (!isset($_GET['id_product']) || $_GET['id_product'] != $id_product)) {
$productImagesData[$id_product]['link'] = $link->getProductLink($id_product, $lrw);
} else {
$productImagesData[$id_product]['link'] = '';
}
$productImagesData[$id_product]['title'] = $productViewedObj->name;
$productImagesData[$id_product]['thumb'] = $_link->getImageLink($lrw, $productViewedObj->cover, 'small');
if ($tool->type == 'circle') {
$productImagesData[$id_product]['medium'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('thumb-image'));
$productImagesData[$id_product]['img'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('large-image'));
} else {
$productImagesData[$id_product]['img'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('thumb-image'));
}
}
}
$magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => "blockviewedMagicZoomPlus"));
$pattern = '<ul[^>]*?>.*?<\\/ul>';
$output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output);
break;
case 'blockbestsellers':
$blockbestsellers = true;
case 'blocknewproducts':
if (isset($blockbestsellers)) {
//$products = $smarty->$getTemplateVars('best_sellers');
//to get with description etc.
$products = ProductSale::getBestSales(intval($cookie->id_lang), 0, 4);
} else {
$products = $smarty->{$getTemplateVars}('new_products');
}
$pCount = count($products);
if (!$pCount || !$products) {
break;
}
$GLOBALS['magictoolbox']['magiczoomplus']['headers'] = true;
$productImagesData = array();
$useLink = !$tool->params->checkValue('link-to-product-page', 'No');
foreach ($products as $p_key => $product) {
if ($useLink && (!isset($_GET['id_product']) || $_GET['id_product'] != $product['id_product'])) {
$productImagesData[$p_key]['link'] = $link->getProductLink($product['id_product'], $product['link_rewrite']);
} else {
$productImagesData[$p_key]['link'] = '';
}
$productImagesData[$p_key]['title'] = $product['name'];
$productImagesData[$p_key]['thumb'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], 'small');
if ($tool->type == 'circle') {
$productImagesData[$p_key]['medium'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image'));
$productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('large-image'));
} else {
$productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image'));
}
}
$magiczoomplus = $tool->getMainTemplate($productImagesData, array("id" => $currentTemplate . "MagicZoomPlus"));
$pattern = '<ul[^>]*?>.*?<\\/ul>';
$output = preg_replace('/' . $pattern . '/is', $magiczoomplus, $output);
break;
}
return self::prepareOutput($output);
}
示例10: buildSubmenuTree
//.........这里部分代码省略.........
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < count($products); $i++) {
if (isset($products[$i]['id_product'])) {
$image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
}
}
$node['content']['productsimg'] = (isset($image_array) and $image_array) ? $image_array : NULL;
}
if ($node['content']['view'] == 1 || $node['content']['view'] == 3) {
$node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']);
$node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']);
$node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']);
$node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']);
$node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']);
}
}
break;
case 2:
if (isset($node['content']['ids'])) {
if ($node['content']['ids'] == 'n') {
if ($node['content']['o'] == 1) {
$products = Product::getNewProducts($id_lang, 0, (int) $node['content']['limit']);
} else {
$products = Product::getNewProducts($id_lang, 0, (int) $node['content']['limit'], false, $node['content']['o'], $node['content']['ob']);
}
} elseif ($node['content']['ids'] == 's') {
if ($node['content']['o'] == 1) {
$products = Product::getPricesDrop($id_lang, 0, (int) $node['content']['limit']);
} else {
$products = Product::getPricesDrop($id_lang, 0, (int) $node['content']['limit'], false, $node['content']['o'], $node['content']['ob']);
}
} elseif ($node['content']['ids'] == 'b') {
$products = ProductSale::getBestSales($id_lang, 0, (int) $node['content']['limit'], 'sales');
} else {
$category = new Category((int) $node['content']['ids'], $id_lang);
if ($node['content']['o'] == 1) {
$products = $category->getProducts($id_lang, 1, (int) $node['content']['limit'], null, null, false, true, true, (int) $node['content']['limit']);
} else {
$products = $category->getProducts($id_lang, 1, (int) $node['content']['limit'], $node['content']['o'], $node['content']['ob']);
}
}
$node['content']['products'] = $products;
$this->addColorsToProductList($node['content']['products']);
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < count($products); $i++) {
if (isset($products[$i]['id_product'])) {
$image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
}
}
$node['content']['productsimg'] = (isset($image_array) and $image_array) ? $image_array : NULL;
}
if ($node['content']['view'] == 1 || $node['content']['view'] == 3) {
$node['content']['line_lg'] = $this->convertGridSizeValue($node['content']['line_lg']);
$node['content']['line_md'] = $this->convertGridSizeValue($node['content']['line_md']);
$node['content']['line_sm'] = $this->convertGridSizeValue($node['content']['line_sm']);
$node['content']['line_ms'] = $this->convertGridSizeValue($node['content']['line_ms']);
$node['content']['line_xs'] = $this->convertGridSizeValue($node['content']['line_xs']);
}
}
break;
case 6:
if (isset($node['content']['source'][$id_lang]) && $node['content']['source'][$id_lang] != '') {
$node['content']['source'] = $node['content']['source'][$id_lang];
} elseif (isset($node['content']['source'][$id_lang_default]) && $node['content']['source'][$id_lang_default] != '') {
示例11: parseTemplateCategory
//.........这里部分代码省略.........
$productImagesData[$p_key]['title'] = $product['name'];
$productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image'));
}
$magicscroll = $tool->getMainTemplate($productImagesData, array("id" => "blockspecialsMagicScroll"));
$pattern = '<ul[^>]*?>.*?<\\/ul>';
$output = preg_replace('/' . $pattern . '/is', $magicscroll, $output);
break;
case 'blockviewed':
$productsViewed = $GLOBALS['magictoolbox']['magicscroll']['productsViewed'];
$pCount = count($productsViewed);
if (!$pCount) {
break;
}
$GLOBALS['magictoolbox']['magicscroll']['headers'] = true;
if ($pCount < $tool->params->getValue('items')) {
$tool->params->setValue('items', $pCount);
}
$productImagesData = array();
$useLink = $tool->params->checkValue('link-to-product-page', 'Yes');
foreach ($productsViewed as $id_product) {
$productViewedObj = new Product(intval($id_product), false, intval($cookie->id_lang));
if (!Validate::isLoadedObject($productViewedObj) or !$productViewedObj->active) {
continue;
} else {
$images = $productViewedObj->getImages(intval($cookie->id_lang));
foreach ($images as $image) {
if ($image['cover']) {
$productViewedObj->cover = $productViewedObj->id . '-' . $image['id_image'];
$productViewedObj->legend = $image['legend'];
break;
}
}
if (!isset($productViewedObj->cover)) {
$productViewedObj->cover = Language::getIsoById($cookie->id_lang) . '-default';
$productViewedObj->legend = '';
}
$lrw = $productViewedObj->link_rewrite;
if ($useLink && (!Tools::getValue('id_product', false) || Tools::getValue('id_product', false) != $id_product)) {
$productImagesData[$id_product]['link'] = $link->getProductLink($id_product, $lrw, $productViewedObj->category);
} else {
$productImagesData[$id_product]['link'] = '';
}
$productImagesData[$id_product]['title'] = $productViewedObj->name;
$productImagesData[$id_product]['img'] = $_link->getImageLink($lrw, $productViewedObj->cover, $tool->params->getValue('thumb-image'));
}
}
$magicscroll = $tool->getMainTemplate($productImagesData, array("id" => "blockviewedMagicScroll"));
$pattern = '<ul[^>]*?>.*?<\\/ul>';
$output = preg_replace('/' . $pattern . '/is', $magicscroll, $output);
break;
case 'blockbestsellers':
case 'blockbestsellers_home':
case 'blocknewproducts':
case 'blocknewproducts_home':
if (in_array($currentTemplate, array('blockbestsellers', 'blockbestsellers_home'))) {
$nb_products = $tool->params->getValue('max-number-of-products', $currentTemplate);
//$products = $smarty->{$this->getTemplateVars}('best_sellers');
//to get with description etc.
$products = ProductSale::getBestSales(intval($cookie->id_lang), 0, $nb_products);
} else {
$products = $smarty->{$this->getTemplateVars}('new_products');
}
if (!is_array($products)) {
break;
}
$pCount = count($products);
if (!$pCount || !$products) {
break;
}
$GLOBALS['magictoolbox']['magicscroll']['headers'] = true;
if ($pCount < $tool->params->getValue('items')) {
$tool->params->setValue('items', $pCount);
}
$productImagesData = array();
$useLink = $tool->params->checkValue('link-to-product-page', 'Yes');
foreach ($products as $p_key => $product) {
if ($useLink && (!Tools::getValue('id_product', false) || Tools::getValue('id_product', false) != $product['id_product'])) {
$productImagesData[$p_key]['link'] = $link->getProductLink($product['id_product'], $product['link_rewrite'], isset($product['category']) ? $product['category'] : null);
} else {
$productImagesData[$p_key]['link'] = '';
}
$productImagesData[$p_key]['title'] = $product['name'];
$productImagesData[$p_key]['img'] = $_link->getImageLink($product['link_rewrite'], $product['id_image'], $tool->params->getValue('thumb-image'));
}
$magicscroll = $tool->getMainTemplate($productImagesData, array("id" => $currentTemplate . "MagicScroll"));
if ($this->isPrestaShop16x) {
if ($currentTemplate == 'blockbestsellers_home') {
$magicscroll = '<div id="blockbestsellers" class="MagicToolboxContainer blockbestsellers tab-pane">' . $magicscroll . '</div>';
} else {
if ($currentTemplate == 'blocknewproducts_home') {
$magicscroll = '<div id="blocknewproducts" class="MagicToolboxContainer blocknewproducts tab-pane active">' . $magicscroll . '</div>';
}
}
}
$pattern = '<ul[^>]*?>.*?<\\/ul>';
$output = preg_replace('/' . $pattern . '/is', $magicscroll, $output);
break;
}
return self::prepareOutput($output);
}