} if (is_numeric($this->get['cid']) and $this->get['cid'] > 0) { if ($this->ms['MODULES']['FLAT_DATABASE']) { $string = '('; for ($i = 0; $i < 4; $i++) { if ($i > 0) { $string .= " or "; } $string .= "categories_id_" . $i . " = '" . $this->get['cid'] . "'"; } $string .= ')'; if ($string) { $filter[] = $string; } } else { $cats = mslib_fe::get_subcategory_ids($this->get['cid']); $cats[] = $this->get['cid']; $filter[] = "p2c.categories_id IN (" . implode(",", $cats) . ")"; } } if (is_array($price_filter)) { if (!$this->ms['MODULES']['FLAT_DATABASE'] and (isset($price_filter[0]) and $price_filter[1])) { $having[] = "(final_price >='" . $price_filter[0] . "' and final_price <='" . $price_filter[1] . "')"; } elseif (isset($price_filter[0])) { $filter[] = "price_filter=" . $price_filter[0]; } } elseif ($price_filter) { $chars = array(); $chars[] = '>'; $chars[] = '<'; foreach ($chars as $char) {
if ($this->ms['MODULES']['FLAT_DATABASE']) { $tbl = 'pf.'; } else { $tbl = 'p2c.'; } $from[] = 'tx_multishop_orders_products mop'; $filter[] = $tbl . "products_id=mop.products_id"; $having[] = "total_quantity > 1"; $select[] = 'COUNT(' . $tbl . 'products_id) as total_quantity'; $orderby[] = 'total_quantity desc'; $categoriesStartingPoint = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categoriesStartingPoint', 's_advanced'); if (!$categoriesStartingPoint and is_numeric($this->conf['categoriesStartingPoint'])) { $categoriesStartingPoint = $this->conf['categoriesStartingPoint']; } if ($categoriesStartingPoint > 0) { $cats = mslib_fe::get_subcategory_ids($categoriesStartingPoint); $cats[] = $categoriesStartingPoint; if ($this->ms['MODULES']['FLAT_DATABASE']) { $tbl = 'pf.'; } else { $tbl = 'p2c.'; } $filter[] = '(' . $tbl . 'categories_id IN (' . implode(",", $cats) . '))'; } $limit_per_page = $this->ms['MODULES']['PRODUCTS_LISTING_LIMIT']; $pageset = mslib_fe::getProductsPageSet($filter, $offset, $this->ms['MODULES']['PRODUCTS_LISTING_LIMIT'], $orderby, $having, $select, $where, 0, $from, array(), 'hot_products', 'p.products_id,COUNT(' . $tbl . 'products_id) as total_quantity'); $products = $pageset['products']; if ($pageset['total_rows'] > 0) { if (strstr($this->ms['MODULES']['PRODUCTS_LISTING_TYPE'], "..")) { die('error in PRODUCTS_LISTING_TYPE value'); } else {
} if (is_numeric($parent_id) and $parent_id > 0) { if ($this->ms['MODULES']['FLAT_DATABASE']) { $string = '('; for ($i = 0; $i < 4; $i++) { if ($i > 0) { $string .= " or "; } $string .= "categories_id_" . $i . " = '" . $parent_id . "'"; } $string .= ')'; if ($string) { $filter[] = $string; } } else { $cats = mslib_fe::get_subcategory_ids($parent_id); $cats[] = $parent_id; $filter[] = "p2c.categories_id IN (" . implode(",", $cats) . ")"; } } //error_log(print_r($filter,1)); $pageset = mslib_fe::getProductsPageSet($filter, $offset, $limit, $orderby, $having, $select, $where, 0, array(), array(), 'admin_ajax_products_search'); $resultset['products'] = $pageset; $max_page = ceil($pageset['total_rows'] / $limit); if ($pageset['total_rows'] > $limit && $p + 1 < $max_page) { $have_paging = true; } if ($pageset['total_rows'] > 0) { $results_counter++; } }
} } else { $main_get_subscat = array(); if (isset($this->post['tx_multishop_pi1']['categories']) && count($this->post['tx_multishop_pi1']['categories'])) { foreach ($this->post['tx_multishop_pi1']['categories'] as $post_main_catid) { $tmp_man_get_subscat = mslib_fe::get_subcategory_ids($post_main_catid); foreach ($tmp_man_get_subscat as $tmp_subs_catid) { $main_get_subscat[] = $tmp_subs_catid; } } if (!count($main_get_subscat)) { $main_get_subscat = implode(',', $this->post['tx_multishop_pi1']['categories']); } } else { if (isset($this->get['categories_id']) && $this->get['categories_id'] > 0) { $main_get_subscat = mslib_fe::get_subcategory_ids($this->get['categories_id']); //$man_catsubs_id_data[] = $this->get['categories_id']; if (!count($main_get_subscat)) { $main_get_subscat[] = $this->get['categories_id']; } } } if (count($main_get_subscat)) { $query_opt_2_values = $GLOBALS['TYPO3_DB']->SELECTquery('DISTINCT(pov.products_options_values_id), CONVERT(SUBSTRING(pov.products_options_values_name, LOCATE(\'-\', pov.products_options_values_name) + 1), SIGNED INTEGER) as sorting, pov.products_options_values_name', 'tx_multishop_products_options_values pov, tx_multishop_products_options_values_to_products_options povp, tx_multishop_products_attributes pa, tx_multishop_products p, tx_multishop_products_to_categories p2c', "pov.language_id='" . $this->sys_language_uid . "' and povp.products_options_id = " . $row['products_options_id'] . " and pa.options_id='" . $row['products_options_id'] . "' and pa.options_values_id=pov.products_options_values_id and pa.products_id=p.products_id and p.page_uid='" . $this->showCatalogFromPage . "' and pov.products_options_values_id=povp.products_options_values_id and p.products_id = p2c.products_id AND p2c.node_id in (" . implode(',', $main_get_subscat) . ")" . (is_array($this->post['tx_multishop_pi1']['manufacturers']) && count($this->post['tx_multishop_pi1']['manufacturers']) ? ' and p.manufacturers_id in (' . implode(',', $this->post['tx_multishop_pi1']['manufacturers']) . ')' : ''), '', $order_column . " " . $order_by, ''); } else { $query_opt_2_values = $GLOBALS['TYPO3_DB']->SELECTquery('DISTINCT(pov.products_options_values_id), CONVERT(SUBSTRING(pov.products_options_values_name, LOCATE(\'-\', pov.products_options_values_name) + 1), SIGNED INTEGER) as sorting, pov.products_options_values_name', 'tx_multishop_products_options_values pov, tx_multishop_products_options_values_to_products_options povp, tx_multishop_products_attributes pa, tx_multishop_products p', "pov.language_id='" . $this->sys_language_uid . "' and povp.products_options_id = " . $row['products_options_id'] . " and pa.options_id='" . $row['products_options_id'] . "' and pa.options_values_id=pov.products_options_values_id and pa.products_id=p.products_id and p.page_uid='" . $this->showCatalogFromPage . "' and pov.products_options_values_id=povp.products_options_values_id" . (is_array($this->post['tx_multishop_pi1']['manufacturers']) && count($this->post['tx_multishop_pi1']['manufacturers']) ? ' and p.manufacturers_id in (' . implode(',', $this->post['tx_multishop_pi1']['manufacturers']) . ')' : ''), '', $order_column . " " . $order_by, ''); } } $res_opt_2_values = $GLOBALS['TYPO3_DB']->sql_query($query_opt_2_values); if (!$this->ms['MODULES']['FLAT_DATABASE']) { $prefix = 'p';
$relations_data[] = $rows['products_id']; } } } } $filter = array(); if (strlen($this->post['keypas']) > 1) { $filter[] = "A.products_name LIKE '%" . trim(mslib_befe::strtolower($this->post['keypas'])) . "%'"; } $filter[] = "p.page_uid='" . $this->showCatalogFromPage . "' and A.products_id=p.products_id"; if (is_array($relations_data) and count($relations_data)) { $filter[] = 'A.products_id NOT IN (' . implode(', ', $relations_data) . ')'; } $subcat_query = ''; if ($this->post['s_cid'] > 0) { $subcats = mslib_fe::get_subcategory_ids($this->post['s_cid'], $subcats); $subcat_queries[] = 'B.categories_id = ' . $this->post['s_cid']; foreach ($subcats as $subcat_id) { $subcat_queries[] = 'B.categories_id = ' . $subcat_id; } $subcat_query = '(' . implode(' OR ', $subcat_queries) . ')'; $filter[] = $subcat_query; } if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('multishop_product_variations')) { $filter[] = 'p.is_hidden=0'; } //die($where); $query = $GLOBALS['TYPO3_DB']->SELECTquery('B.categories_id,C.categories_name', 'tx_multishop_products p, tx_multishop_products_description A INNER JOIN tx_multishop_products_to_categories B ON A.products_id = B.products_id INNER JOIN tx_multishop_categories_description C ON B.categories_id = C.categories_id', implode(" AND ", $filter), 'C.categories_id', 'C.categories_name ASC', ''); // error_log($query); // error_log($query); $pid_regs = array();
public function get_subcategory_ids($parent_id, &$array = array(), $page_uid = '') { if (!is_numeric($parent_id)) { return false; } if (!is_numeric($page_uid)) { $page_uid = $this->showCatalogFromPage; } $str = $GLOBALS['TYPO3_DB']->SELECTquery('c.categories_id, cd.categories_name, c.parent_id', 'tx_multishop_categories c, tx_multishop_categories_description cd', 'c.parent_id = \'' . $parent_id . '\' and c.page_uid=\'' . $page_uid . '\' and c.categories_id = cd.categories_id', '', 'c.sort_order, cd.categories_name', ''); $categories_query = $GLOBALS['TYPO3_DB']->sql_query($str); while ($categories = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($categories_query)) { if (is_numeric($categories['categories_id'])) { $array[] = $categories['categories_id']; } mslib_fe::get_subcategory_ids($categories['categories_id'], $array); } return $array; }
$string .= " or "; } $string .= "pf.categories_id_" . $i . " = '" . $parent_id . "'"; } $string .= ')'; if ($string) { $filter[] = $string; } // } else { $cats = mslib_fe::get_subcategory_ids($parent_id); $cats[] = $parent_id; if (is_array($this->post['categories_id_extra'])) { $cats = array(); foreach ($this->post['categories_id_extra'] as $key_id => $catid) { $cats_extra = mslib_fe::get_subcategory_ids($catid); $cats[] = $catid; $cats = array_merge($cats_extra, $cats); } } $filter[] = "p2c.categories_id IN (" . implode(",", $cats) . ")"; } } if (is_numeric($this->post['min']) and is_numeric($this->post['max'])) { if (!$this->ms['MODULES']['FLAT_DATABASE']) { $having[] = "(final_price BETWEEN '" . $this->post['min'] . "' and '" . $this->post['max'] . "')"; } else { $filter[] = "(pf.final_price BETWEEN '" . $this->post['min'] . "' and '" . $this->post['max'] . "')"; } } $from = array();