本文整理汇总了PHP中Category::getProducts方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getProducts方法的具体用法?PHP Category::getProducts怎么用?PHP Category::getProducts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category
的用法示例。
在下文中一共展示了Category::getProducts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderContent
public function renderContent($setting)
{
$t = array('categorytab' => '', 'categoryBox' => '', 'show_image' => 1, 'show_cat_title' => 1, 'show_description' => 0, 'limit_description' => 25, 'show_sub_category' => 0, 'limit_subcategory' => 5, 'show_nb_product' => 0, 'show_products' => 0, 'limit' => 6, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
$setting = array_merge($t, $setting);
$context = Context::getContext();
//$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false;
$categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array();
//echo "<pre>".print_r($categorytab,1); die;
$categories = $this->getCategories($setting['categoryBox'], $context->language->id);
if ($categories) {
foreach ($categories as &$category) {
$obj = new Category($category['id_category']);
$category['nb_products'] = $obj->getProducts($context->language->id, 0, 1, null, null, true);
$category['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], null, null, false);
$category['id_image'] = file_exists(_PS_CAT_IMG_DIR_ . (int) $category['id_category'] . '.jpg') ? (int) $category['id_category'] : false;
$category['subcategories'] = $this->getSubCategories($category['id_category'], $setting['limit_subcategory'], $context->language->id);
$tg = isset($categorytab[$category['id_category']]) ? $categorytab[$category['id_category']] : '';
if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['icon'])) {
$category['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['icon'];
} else {
$category['icon'] = '';
}
$category['icon_class'] = $tg['icon_class'];
}
}
$setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
$setting['categories_info'] = $categories;
$output = array('type' => 'categoriesinfo', 'data' => $setting);
return $output;
}
示例2: 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;
}
示例3: renderContent
/**
*
*/
public function renderContent($setting)
{
$t = array('categorytab' => '', 'categoryBox' => '', 'limit' => 6, 'itemsperpage' => 4, 'columns' => 4, 'order_by' => 'date_add DESC', 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
$setting = array_merge($t, $setting);
$porder = preg_split('#\\s+#', $setting['order_by']);
if (!isset($porder[1])) {
$porder[1] = null;
}
$output = array();
$context = Context::getContext();
$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false;
$categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array();
if ($categories) {
$tg = array();
foreach ($categories as $id_category) {
$obj = new Category($id_category, $context->language->id);
$tg['category_info'] = isset($categorytab[$id_category]) ? $categorytab[$id_category] : '';
if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['category_info']['icon'])) {
$tg['category_info']['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['category_info']['icon'];
} else {
$tg['category_info']['icon'] = '';
}
$tg['category_obj'] = $obj;
$tg['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], $porder[0], $porder[1]);
$output[] = $tg;
}
}
$setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
$setting['categories_tabs'] = $output;
$output = array('type' => 'categoriestabs', 'data' => $setting);
return $output;
}
示例4: renderContent
public function renderContent($args, $setting)
{
$t = array('name' => '', 'html' => '');
$setting = array_merge($t, $setting);
$nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6;
$catids = $setting['categories'] ? $setting['categories'] : array();
$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;
$categories = array();
foreach ($catids as $catid) {
$category = new Category($catid, (int) Context::getContext()->language->id);
if ($category->id) {
$categories[$catid]['id'] = $category->id;
$categories[$catid]['name'] = $category->name;
$categories[$catid]['link'] = $category->getLink();
$products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
Context::getContext()->controller->addColorsToProductList($products);
$categories[$catid]['products'] = $products;
}
}
$setting['leocategories'] = $categories;
$setting['itemsperpage'] = $items_page;
$setting['columnspage'] = $columns_page;
$setting['scolumn'] = 12 / $columns_page;
$setting['myTab'] = 'leocategorytab' . rand(20, rand());
$output = array('type' => 'categoriestabs', 'data' => $setting);
return $output;
}
示例5: hookblockPosition3
public function hookblockPosition3($params)
{
$arrayCategory = array();
$catSelected = Configuration::get($this->name . '_list_cate');
$cateArray = explode(',', $catSelected);
$id_lang = (int) Context::getContext()->language->id;
$id_shop = (int) Context::getContext()->shop->id;
$arrayProductCate = array();
foreach ($cateArray as $id_category) {
$id_category = str_replace('CAT', '', $id_category);
$category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
$categoryProducts = $category->getProducts($this->context->language->id, 0, 20);
$child_cate = Category::getChildren($id_category, $id_lang);
$categoryids = $this->getimage($id_category, $id_shop);
foreach ($categoryids as $categoryid) {
}
$html = '';
$files = scandir(_PS_CAT_IMG_DIR_);
if (count($files) > 0) {
foreach ($files as $value => $file) {
if (preg_match('/' . $id_category . '-([0-9])?_thumb.jpg/i', substr($file, 0)) === 1) {
if (preg_match('/' . $id_category . '-([0-9])?_thumb.jpg/i', substr($file, 1)) != 1) {
$html .= '<img alt="img" class="img-responsive cate_thumb_icon" src="' . $this->context->link->getMediaLink(_THEME_CAT_DIR_ . $file) . '"/>';
}
}
}
}
if ($categoryProducts) {
$arrayProductCate[] = array('id' => $id_category, 'html' => $html, 'name' => $category->name, 'product' => $categoryProducts, 'child_cate' => $child_cate, 'cate_id' => $categoryid);
}
}
$this->smarty->assign(array('productCates' => $arrayProductCate));
return $this->display(__FILE__, 'poscategorythumb.tpl');
}
示例6: hookHome
function hookHome($params)
{
global $smarty;
$category = new Category(1);
$nb = intval(Configuration::get('HOME_FEATURED_NBR'));
$products = $category->getProducts(intval($params['cookie']->id_lang), 1, $nb ? $nb : 10);
$smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home')));
return $this->display(__FILE__, 'homefeatured.tpl');
}
示例7: hookHome
function hookHome($params)
{
global $smarty;
$category = new Category(1);
$nb = intval(Configuration::get('HOME_FEATURED_NBR'));
$products = $category->getProducts(intval($params['cookie']->id_lang), 1, $nb ? $nb : 10);
$smarty->assign(array('allow_buy_when_out_of_stock' => Configuration::get('PS_ORDER_OUT_OF_STOCK', false), 'max_quantity_to_allow_display' => Configuration::get('PS_LAST_QTIES'), 'category' => $category, 'products' => $products, 'currency' => new Currency(intval($params['cart']->id_currency)), 'lang' => Language::getIsoById(intval($params['cookie']->id_lang)), 'productNumber' => sizeof($products), 'homeSize' => Image::getSize('home')));
return $this->display(__FILE__, 'homefeatured.tpl');
}
示例8: hookHomeCategory
function hookHomeCategory($params)
{
global $smarty;
if (isset($_GET['id_category'])) {
$categoryid = $_GET['id_category'];
}
$category = new Category($categoryid, Configuration::get('PS_LANG_DEFAULT'));
$products1 = $category->getProducts((int) $params['cookie']->id_lang, 1, 3, 'date_add', 'DESC');
$smarty->assign(array('products1' => $products1, 'homeSize' => Image::getSize('home')));
return $this->display(__FILE__, 'blocknewproduct.tpl');
}
示例9: renderContent
public function renderContent($setting)
{
$t = array('id_parent' => '', 'limit' => '12', 'image_width' => '200', 'image_height' => '200');
$setting = array_merge($t, $setting);
$nb = (int) $setting['limit'];
$category = new Category($setting['id_parent'], $this->lang_id);
$products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
$setting['products'] = $products;
$output = array('type' => 'productcategory', 'data' => $setting);
return $output;
}
示例10: renderContent
public function renderContent($args, $setting)
{
$t = array('name' => '', 'html' => '');
$setting = array_merge($t, $setting);
$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 = $setting['interval'] ? (int) $setting['interval'] : 8000;
$iso_code = Context::getContext()->language->iso_code;
$setting['tabs'] = array();
$result['products'] = array();
if ($setting['leotab']) {
$tabs = $setting['leotab'];
$items = $this->getTabs($tabs);
foreach ($items as $item) {
if ($item['categories'] || $item['type']) {
$categories = $item['categories'] ? implode($item['categories'], ",") : '';
$where = '';
if ($categories) {
$where = 'cp.`id_category` IN (' . $categories . ') AND ';
}
if ($item['type'] == 'new') {
$result['products'] = $this->getNewProducts($where, (int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway);
} elseif ($item['type'] == 'special') {
$result['products'] = $this->getPricesDrop($where, (int) Context::getContext()->language->id, 0, $nb, false, $orderby, $orderway);
} elseif ($item['type'] == 'bestseller') {
$result['products'] = $this->getBestSales($where, (int) Context::getContext()->language->id, 0, $nb, $orderby, $orderway);
} elseif ($item['type'] == 'featured') {
$category = new Category(Context::getContext()->shop->getCategory(), (int) Context::getContext()->language->id);
$result['products'] = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
} else {
if ($categories) {
$where = 'WHERE cp.`id_category` IN (' . $categories . ')';
}
$result['products'] = $this->getProducts($where, (int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
}
$result['title'] = $item['title_' . $iso_code] ? $item['title_' . $iso_code] : '';
$result['icon'] = $item['icon'] ? $item['icon'] : '';
$result['id_tab'] = $item['id_tab'] ? $item['id_tab'] : 0;
$setting['tabs'][] = $result;
}
}
}
$setting['itemsperpage'] = $items_page;
$setting['columnspage'] = $columns_page;
$setting['interval'] = $interval;
$setting['path'] = __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/img/icontab/';
$setting['scolumn'] = 12 / $columns_page;
$setting['myTab'] = 'advancetab' . rand(20, rand());
$output = array('type' => 'advancetab', 'data' => $setting);
return $output;
}
示例11: renderContent
public function renderContent($setting)
{
$t = array('category_id' => '', 'limit' => '12', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
$setting = array_merge($t, $setting);
$nb = (int) $setting['limit'];
$category = new Category($setting['category_id'], $this->lang_id);
$products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
$setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
$setting['products'] = $products;
$output = array('type' => 'products', 'data' => $setting);
return $output;
}
示例12: renderContent
public function renderContent($setting)
{
$t = array('category_id' => '', 'limit' => '12', 'image_width' => '200', 'image_height' => '200', 'image' => '', 'banner_imagefile' => '', 'imageurl' => '', 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
$setting = array_merge($t, $setting);
$nb = (int) $setting['limit'];
if ($setting['banner_imagefile']) {
$setting['bannerurl'] = _PAGEBUILDER_IMAGE_URL_ . $setting['banner_imagefile'];
}
$category = new Category($setting['category_id'], $this->lang_id);
$products = $category->getProducts((int) $this->lang_id, 1, $nb ? $nb : 8);
$setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
$setting['products'] = $products;
$output = array('type' => 'products', 'data' => $setting);
return $output;
}
示例13: 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;
}
示例14: 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;
}
示例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;
}
}