本文整理汇总了PHP中Product::getNewProducts方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getNewProducts方法的具体用法?PHP Product::getNewProducts怎么用?PHP Product::getNewProducts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product::getNewProducts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookHome
function hookHome($params)
{
global $smarty;
$products = Product::getNewProducts((int) $params['cookie']->id_lang, 0, 5);
$smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home')));
return $this->display(__FILE__, 'blocknewestproducts.tpl');
}
示例2: hookRightColumn
function hookRightColumn($params)
{
global $smarty;
$newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, intval(Configuration::get('NEW_PRODUCTS_NBR')));
$smarty->assign(array('new_products' => $newProducts, 'mediumSize' => Image::getSize('medium')));
return $this->display(__FILE__, 'blocknewproducts.tpl');
}
示例3: initContent
public function initContent()
{
parent::initContent();
$this->productSort();
// Override default configuration values: cause the new products page must display latest products first.
if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
$this->orderBy = 'date_add';
$this->orderWay = 'DESC';
}
$nb_products = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
$this->pagination($nb_products);
$products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $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' => (int) $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
}
示例4: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->productSort();
// Override default configuration values: cause the new products page must display latest products first.
if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
$this->orderBy = 'date_add';
$this->orderWay = 'DESC';
}
$nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true);
$this->pagination($nbProducts);
$products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $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' => (int) $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_ . 'new-products.tpl');
}
}
示例5: renderContent
public function renderContent($setting)
{
$t = array('list_type' => '', 'limit' => 12, 'image_width' => '200', 'image_height' => '200');
$products = array();
$setting = array_merge($t, $setting);
switch ($setting['list_type']) {
case 'newest':
$products = Product::getNewProducts($this->lang_id, 0, (int) $setting['limit']);
break;
case 'featured':
$category = new Category(Context::getContext()->shop->getCategory(), $this->lang_id);
$nb = (int) $setting['limit'];
$products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
break;
case 'bestseller':
$products = ProductSale::getBestSalesLight((int) $this->lang_id, 0, (int) $setting['limit']);
break;
case 'special':
$products = Product::getPricesDrop($this->lang_id, 0, (int) $setting['limit']);
break;
}
$setting['products'] = $products;
$output = array('type' => 'productlist', 'data' => $setting);
return $output;
}
示例6: process
public function process()
{
parent::process();
$this->productSort();
$nbProducts = (int) Product::getNewProducts((int) self::$cookie->id_lang, isset($this->p) ? (int) $this->p - 1 : NULL, isset($this->n) ? (int) $this->n : NULL, true);
$this->pagination($nbProducts);
self::$smarty->assign(array('products' => Product::getNewProducts((int) self::$cookie->id_lang, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize('home')));
}
示例7: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->productSort();
$nbProducts = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
$this->pagination($nbProducts);
$this->context->smarty->assign(array('products' => Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
}
示例8: displayMain
public function displayMain()
{
global $smarty;
$this->loadFilter();
$products = Product::getNewProducts($this->p, $this->n, $this->by, $this->way);
$this->pagination($products['total']);
$smarty->assign(array('products' => $products['entitys']));
return $smarty->fetch('new-products.tpl');
}
示例9: hookhome
function hookhome($params)
{
global $smarty;
$newProducts = Product::getNewProducts((int) $params['cookie']->id_lang, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
if (!$newProducts and !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
return;
}
$smarty->assign(array('new_products' => $newProducts, 'homeSize' => Image::getSize('home_default')));
return $this->display(__FILE__, 'tdnewproducts.tpl');
}
示例10: getNewProducts
private function getNewProducts()
{
if (!Configuration::get('NEW_PRODUCTS_NBR_TM')) {
return;
}
$newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR_TM'));
if (!$newProducts && Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
return;
}
return $newProducts;
}
示例11: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->productSort();
// Override default configuration values: cause the new products page must display latest products first.
if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
$this->orderBy = 'date_add';
$this->orderWay = 'DESC';
}
$nbProducts = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
$this->pagination($nbProducts);
$this->context->smarty->assign(array('products' => Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
}
示例12: hookRightColumn
function hookRightColumn($params)
{
global $smarty;
$currency = new Currency(intval($params['cookie']->id_currency));
$newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'));
$new_products = array();
if ($newProducts) {
foreach ($newProducts as $newProduct) {
$new_products[] = $newProduct;
}
}
$smarty->assign(array('new_products' => $new_products, 'mediumSize' => Image::getSize('medium')));
return $this->display(__FILE__, 'blocknewproducts.tpl');
}
示例13: getNewProducts
protected function getNewProducts()
{
if (!Configuration::get('NEW_PRODUCTS_NBR')) {
return;
}
$newProducts = false;
if (Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) {
$newProducts = Product::getNewProducts((int) $this->context->language->id, 0, (int) Configuration::get('NEW_PRODUCTS_NBR'));
}
if (!$newProducts && Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY')) {
return;
}
return $newProducts;
}
示例14: renderContent
public function renderContent($args, $setting)
{
# validate module
unset($args);
$t = array('name' => '', 'html' => '');
$setting = array_merge($t, $setting);
$nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 8;
$orderby = $setting['orderby'] ? $setting['orderby'] : 'date_add';
$orderway = $setting['orderway'] ? $setting['orderway'] : 'date_add';
$items_page = $columns_page = 3;
if (isset($setting['itemspage']) && $setting['itemspage']) {
$items_page = $setting['itemspage'];
}
if (isset($setting['columns']) && $setting['columns']) {
$columns_page = $setting['columns'];
}
$interval = isset($setting['interval']) ? (int) $setting['interval'] : 8000;
switch ($setting['specialtype']) {
case 'newest':
$products = Product::getNewProducts($this->langID, 0, $nb, false, $orderby, $orderway);
break;
case 'featured':
$category = new Category(Context::getContext()->shop->getCategory(), $this->langID);
$products = $category->getProducts((int) $this->langID, 1, $nb, $orderby, $orderway);
break;
case 'bestseller':
$products = ProductSale::getBestSalesLight((int) $this->langID, 0, $nb);
break;
case 'special':
$products = Product::getPricesDrop($this->langID, 0, $nb, false, $orderby, $orderway);
break;
case 'random':
$random = true;
$products = $this->getProducts('WHERE p.id_product > 0', (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway, false, true, $random, $nb);
Configuration::updateValue('LEO_CURRENT_RANDOM_CACHE', '1');
break;
}
$setting['specialtype'] = $setting['specialtype'];
Context::getContext()->controller->addColorsToProductList($products);
$setting['products'] = $products;
$setting['itemsperpage'] = $items_page;
$setting['columnspage'] = $columns_page;
$setting['scolumn'] = 12 / $columns_page;
$setting['interval'] = $interval;
$setting['tab'] = 'leospecialproduct' . rand(20, rand());
$output = array('type' => 'specialproduct', 'data' => $setting);
return $output;
}
示例15: _getProducts
/**
* Récupération de la liste des produits
* @param string $type
* @param int $nb_products
*/
protected function _getProducts($type, $nb_products)
{
switch ($type) {
case 'price_drop':
return Product::getPricesDrop((int) $this->context->language->id, 0, $nb_products);
break;
case 'category':
$this->_datas['id_category'] ? $id_category = $this->_datas['id_category'] : ($id_category = (int) Configuration::get('HOME_FEATURED_CAT'));
$category = new Category($id_category, (int) $this->context->language->id);
return $category->getProducts((int) $this->context->language->id, 1, $nb_products, 'position');
break;
case 'new':
default:
return Product::getNewProducts((int) $this->context->language->id, 0, $nb_products);
break;
}
}