<?php
/**
* @version 3.7.1 20.11.2011
* @author MAXXmarketing GmbH
* @package Jshopping
* @copyright Copyright (C) 2010 webdesigner-profi.de. All rights reserved.
* @license GNU/GPL
*/
defined('_JEXEC') or die('Restricted access');
class jshopCategory extends JTableAvto{
[color=red][b]function getAllCatCountProducts(){
$db = JFactory::getDBO();
$query = "SELECT category_id, count(product_id) as k FROM `#__jshopping_products_to_categories`
AS prod LEFT JOIN `#__jshopping_products` AS pr_cat USING (product_id) where product_publish=1
group by category_id";
$db->setQuery($query);
$list = $db->loadObjectList();
$rows = array();
foreach($list as $row){
$rows[$row->category_id] = $row->k;
}
return $rows;
}[/b][/color]
function __construct( &$_db ){
parent::__construct( '#__jshopping_categories', 'category_id', $_db );
}
function getSubCategories($parentId, $order = 'id', $ordering = 'asc', $publish = 0) {
$lang = JSFactory::getLang();
$user = JFactory::getUser();
$add_where = ($publish)?(" AND category_publish = '1' "):("");
$groups = implode(',', $user->getAuthorisedViewLevels());
$add_where .=' AND access IN ('.$groups.')';
if ($order=="id") $orderby = "category_id";
if ($order=="name") $orderby = "`".$lang->get('name')."`";
if ($order=="ordering") $orderby = "ordering";
if (!$orderby) $orderby = "ordering";
$query = "SELECT `".$lang->get('name')."` as name,`".$lang->get('description')."` as description,`".$lang->get('short_description')."` as short_description, category_id, category_publish, ordering, category_image FROM `#__jshopping_categories`
WHERE category_parent_id = '" . $this->_db->escape($parentId). "'" . $add_where . "
ORDER BY ".$orderby." ".$ordering;
$this->_db->setQuery($query);
$categories = $this->_db->loadObjectList();
foreach($categories as $key=>$value){
$categories[$key]->category_link = SEFLink('index.php?option=com_jshopping&controller=category&task=view&category_id='.$categories[$key]->category_id, 1);
}
return $categories;
}
function getName() {
$lang = JSFactory::getLang();
$name = $lang->get('name');
return $this->$name;
}
function getDescription(){
if (!$this->category_id){
$this->getDescriptionMainPage();
return 1;
}
$lang = JSFactory::getLang();
$name = $lang->get('name');
$description = $lang->get('description');
$short_description = $lang->get('short_description');
$meta_title = $lang->get('meta_title');
$meta_keyword = $lang->get('meta_keyword');
$meta_description = $lang->get('meta_description');
$this->name = $this->$name;
$this->description = $this->$description;
$this->short_description = $this->$short_description;
$this->meta_title = $this->$meta_title;
$this->meta_keyword = $this->$meta_keyword;
$this->meta_description = $this->$meta_description;
}
function getTreeChild() {
$category_parent_id = $this->category_parent_id;
$i = 0;
$list_category = array();
$list_category[$i]->category_id = $this->category_id;
$list_category[$i]->name = $this->name;
$i++;
while($category_parent_id) {
$category = JTable::getInstance('category', 'jshop');
$category->load($category_parent_id);
$list_category[$i]->category_id = $category->category_id;
$list_category[$i]->name = $category->getName();
$category_parent_id = $category->category_parent_id;
$i++;
}
$list_category = array_reverse($list_category);
return $list_category;
}
function getAllCategories($publish = 1, $access = 1) {
$db = JFactory::getDBO();
$user = JFactory::getUser();
$where = array();
if ($publish){
$where[] = "category_publish = '1'";
}
if ($access){
$groups = implode(',', $user->getAuthorisedViewLevels());
$where[] =' access IN ('.$groups.')';
}
$add_where = "";
if (count($where)){
$add_where = " where ".implode(" and ", $where);
}
$query = "SELECT category_id, category_parent_id FROM `#__jshopping_categories` ".$add_where." ORDER BY ordering";
$db->setQuery($query);
return $db->loadObjectList();
}
function getChildCategories($order, $ordering = 'asc', $publish = 1) {
$cats = $this->getSubCategories($this->category_id, $order, $ordering, $publish);
return $cats;
}
function getSisterCategories($order, $ordering = 'asc', $publish = 1) {
$cats = $this->getSubCategories($this->category_parent_id, $order, $ordering, $publish);
return $cats;
}
function getTreeParentCategories($publish = 1, $access = 1){
$user = JFactory::getUser();
$cats_tree = array();
$category_parent = $this->category_id;
$where = array();
if ($publish){
$where[] = "category_publish = '1'";
}
if ($access){
$groups = implode(',', $user->getAuthorisedViewLevels());
$where[] =' access IN ('.$groups.')';
}
$add_where = "";
if (count($where)){
$add_where = "and ".implode(" and ", $where);
}
while($category_parent) {
$cats_tree[] = $category_parent;
$query = "SELECT category_parent_id FROM `#__jshopping_categories` WHERE category_id = '".$this->_db->escape($category_parent)."' ".$add_where;
$this->_db->setQuery($query);
$rows = $this->_db->loadObjectList();
$category_parent = $rows[0]->category_parent_id;
}
return array_reverse($cats_tree);
}
function getProducts($filters, $order = null, $orderby = null, $limitstart = 0, $limit = 0) {
$jshopConfig = JSFactory::getConfig();
$adv_query = ""; $adv_from = ""; $adv_result = $this->getBuildQueryListProductDefaultResult();
$this->getBuildQueryListProduct("category", "list", $filters, $adv_query, $adv_from, $adv_result);
$order_query = $this->getBuildQueryOrderListProduct($order, $orderby, $adv_from);
JPluginHelper::importPlugin('jshoppingproducts');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeQueryGetProductList', array("category", &$adv_result, &$adv_from, &$adv_query, &$order_query, &$filters) );
$query = "SELECT $adv_result FROM `#__jshopping_products` AS prod
LEFT JOIN `#__jshopping_products_to_categories` AS pr_cat USING (product_id)
$adv_from
WHERE pr_cat.category_id = '".$this->_db->escape($this->category_id)."' AND prod.product_publish = '1' ".$adv_query." ".$order_query;
if ($limit){
$this->_db->setQuery($query, $limitstart, $limit);
}else{
$this->_db->setQuery($query);
}
$products = $this->_db->loadObjectList();
$products = listProductUpdateData($products);
return $products;
}
function getCountProducts($filters){
$jshopConfig = JSFactory::getConfig();
$adv_query = ""; $adv_from = ""; $adv_result = "";
$this->getBuildQueryListProduct("category", "count", $filters, $adv_query, $adv_from, $adv_result);
JPluginHelper::importPlugin('jshoppingproducts');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger( 'onBeforeQueryCountProductList', array("category", &$adv_result, &$adv_from, &$adv_query, &$filters) );
$query = "SELECT count(pr_cat.product_id) FROM `#__jshopping_products_to_categories` AS pr_cat
INNER JOIN `#__jshopping_products` AS prod ON pr_cat.product_id = prod.product_id
$adv_from
WHERE pr_cat.category_id = '".$this->_db->escape($this->category_id)."' AND prod.product_publish = '1' ".$adv_query;
$this->_db->setQuery($query);
return $this->_db->loadResult();
}
function getDescriptionMainPage(){
$statictext = JTable::getInstance("statictext","jshop");
$row = $statictext->loadData("home");
$this->description = $row->text;
$seo = JTable::getInstance("seo","jshop");
$row = $seo->loadData("category");
$this->meta_title = $row->title;
$this->meta_keyword = $row->keyword;
$this->meta_description = $row->description;
}
/**
* get List Manufacturer for this category
*/
function getManufacturers(){
$jshopConfig = JSFactory::getConfig();
$user = JFactory::getUser();
$lang = JSFactory::getLang();
$adv_query = "";
$groups = implode(',', $user->getAuthorisedViewLevels());
$adv_query .=' AND prod.access IN ('.$groups.')';
if ($jshopConfig->hide_product_not_avaible_stock){
$adv_query .= " AND prod.product_quantity > 0";
}
$query = "SELECT distinct man.manufacturer_id as id, man.`".$lang->get('name')."` as name FROM `#__jshopping_products` AS prod
LEFT JOIN `#__jshopping_products_to_categories` AS categ USING (product_id)
LEFT JOIN `#__jshopping_manufacturers` as man on prod.product_manufacturer_id=man.manufacturer_id
WHERE categ.category_id = '".$this->_db->escape($this->category_id)."' AND prod.product_publish = '1' AND prod.product_manufacturer_id!=0 ".$adv_query." order by name";
$this->_db->setQuery($query);
$list = $this->_db->loadObjectList();
return $list;
}
}
?>
вы наверное добавили в фукцию вьюв , а надо в дисплей...
<?php
/**
* @version 3.9.1 20.05.2012
* @author MAXXmarketing GmbH
* @package Jshopping
* @copyright Copyright (C) 2010 webdesigner-profi.de. All rights reserved.
* @license GNU/GPL
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.controller');
class JshoppingControllerCategory extends JController{
function display(){
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$jshopConfig = JSFactory::getConfig();
$params = $mainframe->getParams();
$category_id = 0;
$ordering = $jshopConfig->category_sorting==1 ? "ordering" : "name";
$category = JTable::getInstance('category', 'jshop');
$category->load($category_id);
$categories = $category->getChildCategories($ordering, 'asc', 1);
$category->getDescription();
JPluginHelper::importPlugin('jshopping');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeDisplayMainCategory', array(&$category, &$categories));
setMetaData($category->meta_title, $category->meta_keyword, $category->meta_description, $params);
if ($jshopConfig->use_plugin_content){
changeDataUsePluginContent($category, "category");
}
$view_name = "category";
$view_config = array("template_path"=>JPATH_COMPONENT."/templates/".$jshopConfig->template."/".$view_name);
$view = $this->getView($view_name, getDocumentType(), '', $view_config);
$view->setLayout("maincategory");
$view->assign('category', $category);
$view->assign('image_category_path', $jshopConfig->image_category_live_path);
$view->assign('noimage', 'noimage.gif');
$view->assign('categories', $categories);
$view->assign('count_category_to_row', $jshopConfig->count_category_to_row);
$view->assign('params', $params);
$dispatcher->trigger('onBeforeDisplayCategoryView', array(&$view) );
[b][color=red]$countproducts = $category->getAllCatCountProducts();
$view->assign('countproducts', $countproducts);[/color][/b]
$view->display();
}
function view(){
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$user = JFactory::getUser();
$jshopConfig = JSFactory::getConfig();
$session = JFactory::getSession();
$session->set("jshop_end_page_buy_product", $_SERVER['REQUEST_URI']);
$session->set("jshop_end_page_list_product", $_SERVER['REQUEST_URI']);
JPluginHelper::importPlugin('jshoppingproducts');
JPluginHelper::importPlugin('jshopping');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onBeforeLoadProductList', array());
$category_id = JRequest::getInt('category_id');
$category = JTable::getInstance('category', 'jshop');
$category->load($category_id);
$category->getDescription();
$dispatcher->trigger('onAfterLoadCategory', array(&$category, &$user));
if ($category->category_publish==0 || !in_array($category->access, $user->getAuthorisedViewLevels())){
JError::raiseError( 404, _JSHOP_PAGE_NOT_FOUND);
return;
}
$manufacturer_id = JRequest::getInt('manufacturer_id');
$label_id = JRequest::getInt('label_id');
$vendor_id = JRequest::getInt('vendor_id');
$view_name = "category";
$view_config = array("template_path"=>JPATH_COMPONENT."/templates/".$jshopConfig->template."/".$view_name);
$view = $this->getView($view_name, getDocumentType(), '', $view_config);
if ($category->category_template=="") $category->category_template="default";
$view->setLayout("category_".$category->category_template);
$jshopConfig->count_products_to_page = $category->products_page;
$context = "jshoping.list.front.product";
$contextfilter = "jshoping.list.front.product.cat.".$category_id;
$orderby = $mainframe->getUserStateFromRequest( $context.'orderby', 'orderby', $jshopConfig->product_sorting_direction, 'int');
$order = $mainframe->getUserStateFromRequest( $context.'order', 'order', $jshopConfig->product_sorting, 'int');
$limit = $mainframe->getUserStateFromRequest( $context.'limit', 'limit', $category->products_page, 'int');
if (!$limit) $limit = $category->products_page;
$limitstart = JRequest::getInt('limitstart');
$orderbyq = getQuerySortDirection($order, $orderby);
$image_sort_dir = getImgSortDirection($order, $orderby);
$field_order = $jshopConfig->sorting_products_field_select[$order];
$filters = getBuildFilterListProduct($contextfilter, array("categorys"));
if (getShopMainPageItemid()==JRequest::getInt('Itemid')){
appendExtendPathWay($category->getTreeChild(), 'category');
}
$orderfield = $jshopConfig->category_sorting==1 ? "ordering" : "name";
$sub_categories = $category->getChildCategories($orderfield, 'asc', $publish = 1);
$dispatcher->trigger( 'onBeforeDisplayCategory', array(&$category, &$sub_categories) );
if ($category->meta_title=="") $category->meta_title = $category->name;
setMetaData($category->meta_title, $category->meta_keyword, $category->meta_description);
$total = $category->getCountProducts($filters);
$action = xhtmlUrl($_SERVER['REQUEST_URI']);
if ($limitstart>=$total) $limitstart = 0;
$products = $category->getProducts($filters, $field_order, $orderbyq, $limitstart, $limit);
addLinkToProducts($products, $category_id);
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
$pagenav = $pagination->getPagesLinks();
foreach($jshopConfig->sorting_products_name_select as $key=>$value){
$sorts[] = JHTML::_('select.option', $key, $value, 'sort_id', 'sort_value' );
}
insertValueInArray($category->products_page, $jshopConfig->count_product_select); //insert category count
foreach ($jshopConfig->count_product_select as $key => $value) {
$product_count[] = JHTML::_('select.option',$key, $value, 'count_id', 'count_value' );
}
$sorting_sel = JHTML::_('select.genericlist', $sorts, 'order', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"','sort_id', 'sort_value', $order );
$product_count_sel = JHTML::_('select.genericlist', $product_count, 'limit', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"','count_id', 'count_value', $limit );
$_review = JTable::getInstance('review', 'jshop');
$allow_review = $_review->getAllowReview();
if (!$category->category_ordertype) $category->category_ordertype = 1;
if ($jshopConfig->show_product_list_filters){
$filter_manufactures = $category->getManufacturers();
$first_manufacturer = array();
$first_manufacturer[] = JHTML::_('select.option', 0, _JSHOP_ALL, 'id', 'name' );
$manufacuturers_sel = JHTML::_('select.genericlist', array_merge($first_manufacturer, $filter_manufactures), 'manufacturers[]', 'class = "inputbox" onchange = "submitListProductFilters()"','id', 'name', $filters['manufacturers'][0]);
}
if ($jshopConfig->use_plugin_content){
changeDataUsePluginContent($category, "category");
}
$display_list_products = (count($products)>0 || willBeUseFilter($filters));
$dispatcher->trigger('onBeforeDisplayProductList', array(&$products) );
$view->assign('config', $jshopConfig);
$view->assign('template_block_list_product', "list_products/list_products.php");
$view->assign('template_block_form_filter', "list_products/form_filters.php");
$view->assign('template_block_pagination', "list_products/block_pagination.php");
$view->assign('path_image_sorting_dir', $jshopConfig->live_path.'images/'.$image_sort_dir);
$view->assign('filter_show', 1);
$view->assign('filter_show_category', 0);
$view->assign('filter_show_manufacturer', 1);
$view->assign('pagination', $pagenav);
$view->assign('pagination_obj', $pagination);
$view->assign('display_pagination', $pagenav!="");
$view->assign('rows', $products);
$view->assign('count_product_to_row', $category->products_row);
$view->assign('image_category_path', $jshopConfig->image_category_live_path);
$view->assign('noimage', 'noimage.gif');
$view->assign('category', $category);
$view->assign('categories', $sub_categories);
$view->assign('count_category_to_row', $jshopConfig->count_category_to_row);
$view->assign('allow_review', $allow_review);
$view->assign('product_count', $product_count_sel);
$view->assign('sorting', $sorting_sel);
$view->assign('action', $action);
$view->assign('orderby', $orderby);
$view->assign('manufacuturers_sel', $manufacuturers_sel);
$view->assign('filters', $filters);
$view->assign('display_list_products', $display_list_products);
$view->assign('shippinginfo', SEFLink('index.php?option=com_jshopping&controller=content&task=view&page=shipping',1));
$dispatcher->trigger('onBeforeDisplayProductListView', array(&$view) );
$view->display();
}
}
?>